jeffmer / SI4732_Espruino

Software for the SI4732-A10 based radios implemented in Espruino
19 stars 4 forks source link

ATS100 #3

Open ra4daj opened 1 year ago

ra4daj commented 1 year ago

Hello! In accordance with the instructions, I downloaded Espruino to my ATS-100, successfully downloaded all the necessary Java scripts using WebIDE, but for some reason the program cannot start. "Loading..." appears on the screen and nothing else happens. What could be the problem, do you think? Sincerely, Victor

ra4daj commented 1 year ago

image

jeffmer commented 1 year ago

Looks like you are missing encoder.js which you can find in the directory above ats100. Apologies for poor documentation. You also need the bands.json file.

ra4daj commented 1 year ago

image

Thank you very much! I entered the file name encoder.js incorrectly. After fixing the error related to this disappeared. But now there was a problem with the display of the picture. How to fix it? And where to look for the bands.js file? I would be grateful for a hint.

jeffmer commented 1 year ago

It’s bands.json in the same place as encoder.js. You need to load the smallradio.png file with the Espruino WebIDE to convert it to an image file named smallradio. Alternatively simply delete the line in chooser.js.

ra4daj commented 1 year ago

I'm sorry for the inconvenience. Figured it out on my own. It turned out that I did not remove the png extension in the image title. And I also found and uploaded the bands.json file. Everything works great. Thank you very much. Best regards, Viktor

jeffmer commented 1 year ago

That’s great - glad you got it to work - if you have any suggestions as to what documentation would have made it easier - do let me know.

ra4daj commented 1 year ago

Hello! Today I checked the operation of the receiver with your firmware. Conflicting impressions. Of course, I liked the direct dialing of frequencies and the ability to store station frequencies in memory. I also liked the lack of mute when setting up in ssb. But there are also bad things. The ticking noise from the display intensified. The display does not go to sleep, and if its brightness is reduced to 0 and then the encoder is turned, it will be a big problem to find the correct position of the encoder to turn the display back on. I think you should prevent the display from going out completely and let it go to sleep after 1-2 minutes of encoder inactivity. When you try to switch the receiver from SSB reception mode to AM reception mode, the patch is not unloaded and reception continues in SSB. When switching from AM to FM, the receiver freezes. That is, changing modes is possible only by turning off the receiver by holding the encoder button for a long time. For surfing the bands, the 5 kHz resolution setting in SSB mode is severely lacking. This discrete tuning is very convenient when searching for stations. I did not like some inhibition in the work of the encoder. He does not have time to track fast turns at all. For some reason, the sound in AM mode has become noticeably quieter than in SSB. This has not been observed before. It seems that this is the action of some kind of noise suppressor built into the si4732, which introduces the dependence of the loudness on the signal-to-noise ratio into the signal processing. I think that in this kind of receiver this is an unnecessary function. It would be great to fix at least some of the above. Best wishes, 73!

ra4daj commented 1 year ago

Hello! I try to complete the firmware in accordance with my ideas about the beautiful :) In order not to get lost in the wild, I corrected the line responsible for the range of brightness adjustment in each of the applications (AM, FM, SSB). The brightness can be reduced, but not to 0: 156 BRIGHT=BRIGHT<0?5:BRIGHT>63?63:BRIGHT; And in order to get the opportunity to change the frequency of settings with a discreteness of 5 kHz in SSB mode, I turned an error into a function. Given the fact that when switching from SSB to AM SSB, the patch is not unloaded from memory, I taught the AM receiver to keep the condition not in amstate, but in ssbstate. Thanks to this trick, it becomes possible to continue taking SSB after the transition from SSB to AM, but move at the discretion of 5 kHz. But as soon as something interesting is found, you can switch the SSB receiver again, and at the same time it will remain in the same place where it was in AM. It is bad that the transition from AM to the SSB causes the next reboot of the SSB patch. But in order to explain to the controller that this should not be done, my knowledge is not enough. 172 s = STOR.readJSON("ssbstate.json",1)||{frequency:1024, volume:32, bright:40, bandwidth:2}; 184 STOR.writeJSON("ssbstate.json",s); By the way, is it possible to make reset Si4732 every time it switches from AM, FM, SSB to the main menu (chooser.js)? And one more question. Is it possible to activate sleep on the display?

ra4daj commented 1 year ago

Stepdisp: class StepDisp { constructor(x,y,d,fn){ this.steps=[5000,1000,100,10]; SSBAPP.JS: var stepindex= 3; const steps =[10,100,1000,5000]; This is how I managed to solve the problem of 5 kHz resolution. Now the receiver is much more suitable for finding new frequencies.

jeffmer commented 1 year ago

Thanks for the feedback - much appreciated.

The selector wheel response gets worse the more processing that is being done - so very bad with RDS on. It may be possible to improve this using hardware interrupt priority or providing a driver in C versus Espruino.

For the step display, do you think it would be better if the cursor was positioned half way between digits to indicate 5Khz step?

When I get a chance, I will look at sleeping the display, it should not be hard.

The si4732 power functions reset the watch,so I am surprised the patch stays loaded - I will have a look.

I also get the low AM volume and there must be some setting to avoid that.

Have you tried an external aerial? Mine did not work very well as the radio sounded like the connection was intermittent even though the physical connection looked solid.

ra4daj commented 1 year ago

As for the cursor between the numbers, it would probably be more correct, but in general it is not important. This is an aesthetic that does not affect usability. And the sleep of the display, the correct switching between the modes AM, FM, SSB - this is really important. A more responsive encoder is desirable, but in general and as it is now tolerable. Quiet AM is, it seems to me, the result of the work of the AGC. In si4732, it is possible to change the AGC response threshold over a wide range. In the original ATS 100 firmware there is a menu item that allows you to control this parameter. Sometimes this is useful. It would be very useful to return such a function to the Espruino firmware. This would make it possible to adapt the sensitivity of the receiver to the on-air environment and antennas. Your firmware, in my opinion, is much better and more convenient than the original version ATS-100, which is beautiful, but at the same time extremely stupid. If you do what I have listed, you will get exactly what we all need.

jeffmer commented 1 year ago

Hi, The latest commit blanks the screen after 30 seconds in each of the radio apps - it comes on again when you rotate the encoder. I have also added your minimum brightness and 5khz step suggestions. The si4732 is now fully reset when switching between apps - so I hope that cures the switching issues.

I will try to add an AGC control to the AM radio when I get a chance.

ra4daj commented 1 year ago

Thank you very much! Loaded. AM-SSB transitions are flawless. But AM-FM and FM-AM transitions still result in a hang. Also, the receiver freezes if you switch to LW in SSB mode and reach the lower limit of the range at any tuning resolution. The display goes to sleep, but I would like to increase the time between the last setting and sleep to about 2 minutes. I wanted to do it myself, but this time I couldn't find a variable that could be set.

jeffmer commented 1 year ago

Hi, look for SCREENSAVE variables in the apps. Initialised to 30 Change all occurrences of 30 related to SCREENSAVE to 120. Will clean it up when I get time.

I do not get any hang ups when switching between apps. I can reproduce the lower limit bug so will fix next.

Latest committ - a new version of amapp now has a button to enable and disable AGC - it is initially disabled. I guess it would be nice to adjust gain level but not much space left for a control:-(

ra4daj commented 1 year ago

Thanks, the timeout on your hint has been fixed. The last thing that would be useful for the convenience of managing the display is to make it wake up not only by turning the encoder, but also by pressing a button. If you want to see what the display is showing without messing up the receiver settings, the most logical way to do this is to press a button. I tried how AGC turned off behaves. The effect was not impressive. Yes, when the AGC is turned off, the receiver is clearly overloaded, but the volume does not increase at all. It looks like the si4732 has some sort of automatic volume control enabled by default. Perhaps this is due to the snr ratio. It is best to disable (or minimize) all of these mufflers if possible. There is little sense from them, only the volume is reduced. In the basic firmware of the ATS-100, most likely all these noise suppressors are disabled. And the AGC adjustment, judging by the effect that it produces there, reduces the gain of si 4732 in steps, without completely turning off the AGC. There is value in such control. Such an attenuator prevents the AGC from recovering excess gain and reduces the chance of overload. I think that the attenuator control could be done on the same principle as switching the bandwidth and tuning step. Each subsequent pressing of the AGC button could turn on its own attenuator, the value of which would be displayed on the AGC button. And you do not need to do a complete shutdown of the AGC. Switching between AM, FM and SSB does not work on my ATS 100. I can switch from AM to SSB but cannot switch from SSB to AM. Rather, the receiver pretends to have switched, but the SSB patch continues to work and LSB is received on SW, and USB on LW-MW. Switching between AM and FM always freezes the receiver.

jeffmer commented 1 year ago

Latest commit has 120 sec screen save + if the screen is blank the first encoder click or button press does not change the state of the radio, it simply turns on the backlight.

AGC control now has agc on, off, low, med, and high states.

I have fixed the 153Khz bug - you can no longer tune below 153Khz - which causes the SI4732 SSB patch to hang.

I suggest you delete your amstate.json, ssbstate.json and fmstate,json files to see if some setting in these cause the hang up which I do not get.

You need to reload the amapp.js, ssbapp.js and fmapp.js files to get the changes above.

BTW AGC on automatically chooses the gain, AGC off is gain 0, AGC low is gain 3, med = 6 and high = 9

ra4daj commented 1 year ago

Now everything is almost perfect. The only thing you can check is to check the status of the following settings: 0x3302 AM_SOFT_MUTE_MAX_ATTENUATION Sets maximum attenuation during soft mute (dB). Set to 0 to disable soft mute. Default is 8 dB. 0x0010 0x4000 RX_VOLUME Sets the output volume. 0x003F All (AN332: Si47xx Programming Guide) Perhaps there is a reserve of AM volume hidden there? As for switching between AM, FM, SSB in my copy of the ATS100, then, probably, the matter is in some kind of timings. Java scripts reinstalled many times, but it did not help. The receiver, when trying to switch, changes the picture on the screen, but once the loaded ssb patch is no longer unloaded from the si 4732 memory. And besides, if I try to switch from FM to AM (or vice versa), a picture of the corresponding range appears on the screen, but the receiver continues to receive the range where it was before switching and no longer reacts to any actions. It remains only to turn it off by long pressing the encoder. This is of course unpleasant, but against the background of the huge pluses of your firmware, this seems like a trifle. By the way, a syntax error crept into the amapp.js script on line 38, which Espruino Web IDE swears at (missing ;). But even without it, everything works.

ra4daj commented 1 year ago

It seems to me that the problem of switching between modes could be radically eliminated if, when exiting any mode, the receiver not only drew the main menu, but also stopped receiving. This does not happen with my receiver. A long press draws the main menu, but does not stop receiving there. where it was before the long press. Most likely this is the problem.

jeffmer commented 1 year ago

That’s interesting because on my receiver after the long press is registered, receiving stops immediately.

The line in main.js

BUTTON.on("longpush",()=>{RADIO.reset();load("chooser.js");});

does this. You do have to release the button after the chooser menu is displayed as if you hold it too long it can switch to another app and then turn off.

ra4daj commented 1 year ago

load("chooser.js" performed, and here: {RADIO.reset doesn't want. The duration of the presses is not affected. After all, after a long press, it should already go into a disabled state. But it does not pass, but continues to work at the frequency where it stood.

jeffmer commented 1 year ago

Hi, the difference between the switch behaviour I see and what you are experiencing maybe to do with the initial state. Can you switch on the Radio and before anything else type ESP32.getState() on the WebIDE.

When I do this I get:

ESP32.getState()
={
  sdkVersion: "v3.1.3-dirty",
  freeHeap: 64572, BLE: true, Wifi: false, minHeap: 59596, cpuFreq: 240000000,
  xtalFreq: 40, apbFreq: 80000000 }
>

If you see that Wifi is true type:- ESP32.enableWifi(false) You only need to do this once and it gives the radio more heap space - which may be the problem.

ra4daj commented 1 year ago

Hello! I tried it and this is what I saw: image Nothing has changed in the behavior of the receiver.

jeffmer commented 1 year ago

That’s a pity. If you check ESP32.getState() presumably wifi is now disabled?

ra4daj commented 1 year ago

image

ra4daj commented 1 year ago

Hello! Recorded 2 short videos illustrating the latest unresolved issues: https://youtu.be/sqHbIOZ4Ltw https://youtu.be/VLaF5sPbHok The first demonstrates how soft mute works, limiting the volume of noisy AM signals. I think the reason for this is hidden in this line of AN 332: 0x3302AM_SOFT_MUTE_MAX_ATTENUATIONSets maximum attenuation during soft mute (dB). Set to 0 to disable soft mute. Default is 8 dB.0x0010Si4730/31/34/35/36/37-B20 and earlier, Si4740/41/42/43/44/45-C10 The noise level on the signal level meter is huge, but because the signal/noise meter is set to 0, the receiver whispers rather than roars at full volume. I think if you completely turn off soft mute, the volume of AM and SSB will become the same.

And on the second video, the behavior of the receiver when trying to switch operating modes. I would like to think that the problem is in the si 4732, but the fact that the modes switch normally on the original firmware does not allow me to think so. Perhaps the duration of the control pulses is shorter than necessary? Or does the command arrive at si 4732 at the wrong time?

ra4daj commented 1 year ago

https://pdf1.alldatasheetru.com/pdfjsview/web/viewer.html?file=//pdf1.alldatasheetru.com/datasheet-pdf/view/630406/SILABS/Si4730/+431W28VPhKCDudVozECY+/datasheet.pdf#page=6&zoom=auto,-15,788 Page 6-7 Probably somewhere here is the cause of the problem with the reset. It is likely that something in the timing of the reset pulses is on the borderline. As a result, some si4732 instances manage to reset, while others do not.

jeffmer commented 1 year ago

HI,

That's very useful, I have now set property 0x3302 to zero in the AM Radio insitialisation and it does increase noise volume.

As you can see from my video - my radio behaves differently

The reset is currently 10ms which is much greater than the 100us mentioned.

However, you can easily adjust reset times in si4735.js lines 18-22. - its definitely worth a try.

I am away for the next weeks so good luck.

jeffmer commented 1 year ago

Actually, there was a timing bug in the reset code:-(

digitalPulse returns immediately. I have fixed it so hopefully this may cure your switch over issue.

Many thanks for your help in improving the software.

ra4daj commented 1 year ago

I seem to understand what the problem is. Thanks a lot for your valuable advice! Judging by lines 18-22 of the si4735.js script, the reset pulse is generated at D 25, but this microcontroller pin is not used in my revision of the receiver (D 33, 32, 35 are used). Most likely, I will need to find which pin of the controller is connected to pin 9 of the si4732 and make a correction in the program. Thank you for the excellent program and extremely fruitful and pleasant communication. All the best to you, 73!

jeffmer commented 1 year ago

Glad you found the problem, let me know which pin it is and I will put a note in the README

ra4daj commented 1 year ago

I apologize for being importunate. Today I messed something up. Foolishly, I decided to replace pin 25 in si4735.js with another one and sent the microcontroller to a cyclic reboot. Somehow, with the help of the flash download tool, I stopped and then re-filled Esprino and Java scripts. But after that the program refuses to work correctly. The window where the frequencies of the ranges should be is empty. I downloaded the firmware from here, it works fine. But Esprino refuses. Please tell me how to fix this?

ra4daj commented 1 year ago

Everything, I figured it out. I forgot to load bands.json and panicked. 1000 apologies for the trouble!

jeffmer commented 1 year ago

Glad you got it to work - have you found the right pin for reset yet?

ra4daj commented 1 year ago

https://photos.app.goo.gl/W5sL3fQXhuektTMo6 Hello! Problem solved. Indeed, the Chinese hung reset si 4732 on 9 physical pin esp 32. Today he removed it from there and transferred it to port 25 pin, as written in your program. And now everything works great. Thank you for the great program and help!