Moving from mikroBasic to OshonSoft Basic

A/D coversion and the entire code simulation is ok, except when values for AN0 are set small.
Then the LCD does not show "Input is too low".
P.S.: The logarythmic signal detector (ahaed of the MCU circuit) output is ca. 0.45 VDC (broadband noise signal) without any input signal applied. In this case I want to display the above message.

again:
Lcdcmdout LcdClear
ADC_Read 0, ADCRead 'Result of A/D conversion from AN0
ADCResult = ADCRead*5/1024
Lcd_Out(1,1, "ADC OUT = " + #ADCResult +" V")
If ADCResult<0.5 Then
Lcd_Out(2,1, "Input is too low")

Else
dBmResult = (ADCResult-ZEROXING)*SLOPE
Lcd_Out(2,1, "PWR = " + #dBmResult + " dBm")
Endif
WaitMs 500
Goto again 'Make a new A/D conversion

Goto main
End
 
Well, I have tested the program in more detail and it seems that in these new versions of the compiler ADC_Read configures the pin as analog and as input. I thought that the problem was that the pin was not output as analog in the simulator. Anyway, if you wanted to do this, it does work.

I didn't see this configure the AN0 pin: Sub GlobInit.


 

Attachments

  • V_dBm_Meter (1).bas
    3.2 KB · Views: 8
Last edited:
Gentlemen,
My project works (simulation and hardware), mission accomplished.
Thank you all who contributed with advice, and help.
I have learnt a lot and will continue exploring OshonBasic.
Best regards,
Robert
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…