Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:00 29 Mar 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Webmite V5.07.08 betas : UDP and other stuff

     Page 5 of 5    
Author Message
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 2989
Posted: 12:30am 19 Aug 2023
Copy link to clipboard 
Print this post

Perhaps the problem is the IF statement--counting as perhaps either 1 or 2 statements depending on the form of the condition.

> list
On error skip 1
i%=(s$=1%)
If MM.Errno Then Print "error: ";MM.Errno;" ";MM.ErrMsg$; " i%=";i%
Print "Done"
> run
error:  16 Incompatible types in expression i%= 0
Done
>


~
Edited 2023-08-19 10:34 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 140
Posted: 12:42am 19 Aug 2023
Copy link to clipboard 
Print this post

  karlelch said  I am experiencing trouble with the latest beta version (5.07.08b11) of the WebMite. I am aware that ideally, I post a short example here, however, I did not yet have time to search for the specific error condition with a respective code snippet. Hence, my question is more if anyone else experienced stability issues with that beta version.

My code can be found here on GitHub.


' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
' MQTT-related routines
'
Sub StartMQTT restart
 ' (Re)connect to MQTT server
 Print Choice(restart, "Restart", "Start") +" MQTT client ..."
 On Error Skip 1
 WEB MQTT Close
 On Error Skip 1
 WEB MQTT Connect MQTT_ADDR$, MQTT_PORT, MQTT_USER$, MQTT_PW$, cb_MQTT
 Local integer errno = MM.Errno
 If errno = 16 Then
   Print "Error (" +Str$(errno) +"): Not connected?"
   _doReboot
 EndIf
 WEB MQTT Subscribe TOP_SOL_PAN
 round = 0
 tLastMsg_s = Timer /1000
 Print "-> done."
End Sub


I'm not able to provide specific help unfortunately but some observations which may trigger some thoughts.

5.07.08b11 has TCP and UDP functionality added. In my attempts to use the TCP client I had a situation where the   status messages were causing some strange behaviour with Exit Sub where no error trapping was being done. I have a


CallSubRoutine


Do
'Nothing
Loop

SomeMoreSubRoutines


structure and I was experiencing program aborts back to console on the Loop terminator when I Sub Exit'ed

CallSubRoutine
ON ERROR SKIP
If MM.ErrNo Then Print "...": Sub Exit
...
End Sub





changing this to


CallSubRoutine
ON ERROR SKIP
If MM.ErrNo Then
 Close TCP Client
 Sub Exit
EndIf
...
End Sub



seemed to make things better behaved.

Maybe there are some MQTT status messages floating around?

I'm also curious as to where you found out that MM.ErrNo = 16 is a failed connection. I was seeing the same 16 in the failed TCP Client. Where did you find an MM.Errno list for the Webmite? I have only seen one for one of the other incarnations of MMBASIC and there 16 was unrelated to TCP as I recall.

If you have not tried Wireshark then I would suggest you give it a try and see what is happening. I found it invaluable resolving some of the ModBus TCP issues I was having.

Best of luck

Cheers
Carl
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 12:48am 19 Aug 2023
Copy link to clipboard 
Print this post

CallSubRoutine
ON ERROR SKIP
If MM.ErrNo Then
Close TCP Client
Exit Sub
EndIf
...
End Sub

You have the order wrong.
SUB EXIT should be EXIT SUB

Jim
VK7JH
MMedit   MMBasic Help
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 12:52am 19 Aug 2023
Copy link to clipboard 
Print this post

  Quote    '
  
BLACK = 0
  
WHITE = 1
  
ON ERROR SKIP 5
  x = y/
0     ' skip 1
  test        
' skip 2
  z = r/
0     ' skip 7/9
  
PRINT MM.ERRMSG$
  
PRINT "got here OK"
  
SUB test
  d = k/
0     ' skip 3
  
IF BLACK = WHITE THEN ' skip 4
    x = f/
0     ' skip 5 if true
    
' exit sub    ' skip 6 if true
  
ENDIF         ' skip 6 if true
  y = g/
0       ' skip 5 if false
  y = p/
0       ' skip 6
  y = p/
0       ' skip 7
END SUB         ' skip 8



play with the SKIP number and IF condition.

Calls to SUBs and the return are counted as far as ON ERROR SKIP is concerned.
IF is counted but ENDIF is only counted if the condition was true.

One at a time is easier.


Jim
VK7JH
MMedit   MMBasic Help
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 140
Posted: 02:13am 19 Aug 2023
Copy link to clipboard 
Print this post

Thanks Jim

That does make it a lot clearer but hasn't helped my confidence.

I shall store this away somewhere as a reference document.

Cheers
Carl
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 140
Posted: 03:52am 19 Aug 2023
Copy link to clipboard 
Print this post

Help please...

I'm trying to setup a single ADC channel on GP26.

I'm using the following configuration per my understanding of the manual

SetPin GP26, AIN 'single ADC channel
SetPin GP27, DIN 'used for PULSIN
DIM ADCOutput!(10) ' take 10 samples
ADC OPEN 250000,1,ADCComplete 'eventually 2 ADC so total still 500kHz

ADC START ADCOutput!() ' called from inside a 10s Tick subroutine

Sub ADCComplete
ADCVoltage=Pin(GP26)
Print ADCVoltage;" Volts"
End Sub


I'm getting this error message on the console

[43] ADCVoltage=Pin(GP26)
Error : Pin 31/GP26 is not an input

What am I missing in setting up the ADC on GP26? Is there some rule about mixed use of the ADC pins, if 1 is declared then they're all declared for ADC? How can an Analog Input declared pin not be an Input? I've checked that there are no other GP26 declarations.

I notice in the v3 manual for the WebMite, Page 61, reference is made to 4 ADC channels, using GP26, GP27, GP28 and GP29. Given that the Pico W only has GP26, GP27 & GP28, I take it this is a typo/carry over from one of the other Mites' manuals.

Thanks
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 05:45am 19 Aug 2023
Copy link to clipboard 
Print this post

  Quote  I'm getting this error message on the console

[43] ADCVoltage=Pin(GP26)
Error : Pin 31/GP26 is not an input


You have to do ADC CLOSE before the pin is available for normal use

SUB ADCComplete
ADC CLOSE
SETPIN GP26, AIN
ADCVoltage=PIN(GP26)
PRINT ADCVoltage;" Volts"
END SUB


It would be better to ask these questions in a separate thread instead of cluttering up the beta announcements.


Jim
Edited 2023-08-19 15:47 by TassyJim
VK7JH
MMedit   MMBasic Help
 
karlelch

Senior Member

Joined: 30/10/2014
Location: Germany
Posts: 145
Posted: 06:29am 19 Aug 2023
Copy link to clipboard 
Print this post

Thanks @carlschneider

  Quote  
I'm also curious as to where you found out that MM.ErrNo = 16 is a failed connection. I was seeing the same 16 in the failed TCP Client. Where did you find an MM.Errno list for the Webmite? I have only seen one for one of the other incarnations of MMBASIC and there 16 was unrelated to TCP as I recall.


Not sure where I found that; must have been here in the forum - maybe when WiFi functionality was introduced - because I also did not find it in the manuals.
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 140
Posted: 02:48pm 19 Aug 2023
Copy link to clipboard 
Print this post

  TassyJim said  You have to do ADC CLOSE before the pin is available for normal use

SUB ADCComplete
ADC CLOSE
SETPIN GP26, AIN
ADCVoltage=PIN(GP26)
PRINT ADCVoltage;" Volts"
END SUB



Thanks Jim. I see it has to be opened again for the next conversion. Changed code to this to make it "free running"

SUB ADCComplete
ADC CLOSE
SETPIN GP26, AIN
ADCVoltage=PIN(GP26)
PRINT ADCVoltage;" Volts"
ADC OPEN 250000,1,ADCComplete
END SUB


Not sure how elegant this is but it's working for now.

  TassyJim said  It would be better to ask these questions in a separate thread instead of cluttering up the beta announcements.


Noted and thanks for the heads up. Very new to this , so learning curve and all that.

I note that there is no specific WebMite Topic unless I've missed it?

Many thanks
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 140
Posted: 02:28am 23 Aug 2023
Copy link to clipboard 
Print this post

Hi there

There appears to be a problem with Pin(temp) on 5.07.0811 which is not present on 5.07.07.

Die temp reported by Pin(temp) on 5.07.07 is rational 29ºC. (Different board PicoW - No ADC running)

Die temp reported on Pin(temp) on 5.07.0811 is irrational 87ºC.(Different Board PicoWH - ADC running)

A bit of research indicates the problem is linked to running the ADC, but caused by outdated pi-sdk/build versions and has been around since early 2021.

https://forums.raspberrypi.com/viewtopic.php?t=303013

Hope this helps
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8516
Posted: 09:28am 23 Aug 2023
Copy link to clipboard 
Print this post

Don't understand what you mean. Are you saying that PIN(TEMP) when you have ADC START operational gives the wrong answer? If so then the answer is of course and perhaps I should block it. If not, please explain
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 140
Posted: 07:29pm 23 Aug 2023
Copy link to clipboard 
Print this post

Hi Peter

  matherp said  Don't understand what you mean. Are you saying that PIN(TEMP) when you have ADC START operational gives the wrong answer? If so then the answer is of course and perhaps I should block it. If not, please explain

I have two Pico boards, one with headers, Pico WH, and the other without headers, Pico W.

The Pico WH board is running Webmite 5.07.0811 while the Pico W board is running 5.07.07.

On the Pico W board running 5.07.07 I have not used the ADC assocuiated with GP26-G28.

On the Pico WH board running 5.07.0811 I have configured GP26-GP28 as ADC inputs. Ultimately GP26 and GP27 will measure temperatures using PT1000 and GP28 will measure the grounded input's noise. Although so far I notice it is less than 1 lsb.

In reading this thread  I came across the use of Pin(temp) to read the die temperature of the RP2040.

Reading Pin(temp) on the Pico WH 5.07.0811 yields an irrational temperature value of 87ºC and remains at that level no matter the time between reads. On the Pico W running 5.07.07 the temperature is a more rational 29ºC. The temperature readings issue is not about accuracy of the reading but about the incorrect reading, specifically when the ADC start is active, or so I thought.

I did some googling and came out at this link https://forums.raspberrypi.com/viewtopic.php?t=303013 which provided some insight into what I was experiencing. At least in this thread they discounted it being a hardware issue and identified that the issue was removed when using updated Pico-SDK and other later git pulls.

Given that the ADC start could be causing the problem I changed the code to stop the ADC and then get the Pin(temp) and then start the ADC again. This however did not solve the problem. I tried commenting out all the ADC commands but this did not solve the problem either.

It looks like this comment from the link above might be relevant.
  Quote  Re: ADC internal temp reading + ADC reading
Mon Feb 08, 2021 9:18 pm

Seems to vary on which uf2 was installed, pre-built or which git clone / Pico-SDK has been used to build it, but I would need to be more methodical in identifying which works, what doesn't.

All I can say is that I installed a different .uf2 and the issue went away.

That may explain why some people are seeing problems while some people may not.

It probably also means it falls into the "Report it to MicoPython forum" category.


and

  Quote  So, this looks to have been a MicroPython / Pico-SDK bug which had been fixed, but people weren't aware of the issue, nor the fix, nor that it had been fixed, nor knew they needed to upgrade, wouldn't have known they had to, and aren't exactly sure how they should.


So from the above perhaps a note that Pin(temp) may not work in 5.07.0811. Perhaps at the next build the updated components will solve the problem...

As far as blocking it is concerned I believe it is a nice feature to have and would advocate for its retention..

Hope this provides the clarity requested.
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 08:48pm 23 Aug 2023
Copy link to clipboard 
Print this post

@Carl,
I have used PIN(TEMP) on 3 different boards all running V5.07.08b11 and all give reliable sensible answers.

If you proved some short run-able code that demonstrates the issue, I will try it here.

Jim
VK7JH
MMedit   MMBasic Help
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3641
Posted: 09:01pm 23 Aug 2023
Copy link to clipboard 
Print this post

Peter would probably also like a nice short sample to show it.

John
 
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 140
Posted: 10:58pm 23 Aug 2023
Copy link to clipboard 
Print this post

Hi there

So after the exhaustive tests below my statement above about the difference between the stable vs beta firmware is inaccurate. It would appear that they both suffer from the same issue...

As requested herewith the required code running on the Pico W

> list
Do
Print "CPUTemp "; Pin(temp)
Pause 1000
Loop


Console output from 5.07.07
CPUTemp  32.18907782
CPUTemp  34.99858673
CPUTemp  34.99858673
CPUTemp  34.99858673
CPUTemp  34.53033525
CPUTemp  34.53033525
CPUTemp  34.53033525
CPUTemp  34.53033525

> option list
WebMite MMBasic Version 5.07.07
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 264000
OPTION DISPLAY 41, 80
OPTION WIFI Actiontec1177, **********
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

> memory
Program:
  1K ( 1%) Program (5 lines)
 79K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  1K ( 0%) 2 Variables
  0K ( 0%) General
105K (100%) Free

On the other Pico WH

Do
Print "CPUTemp "; Pin(temp)
Pause 1000
Loop


Console output from 5.07.0811

> RUN
CPUTemp  30.78432337
CPUTemp  31.25257485

> option list
WebMite MMBasic Version 5.07.08b11
OPTION AUTORUN ON
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 252000
OPTION DISPLAY 41, 140
OPTION WIFI Actiontec1177, **********, PICOE6614103E76
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

> memory
Program:
  1K ( 1%) Program (4 lines)
 79K (99%) Free

Saved Variables:
  1K ( 1%) 1 Saved Variable (15 bytes)
 15K (99%) Free

RAM:
  1K ( 1%) 4 Variables
  0K ( 0%) General
105K (99%) Free

Now introducing the ADC into the equation, first the Pico WH running 5.07.0811


> list
SetPin GP26, AIN
Dim ADC1!(10)
ADC open 166666,1,ADCComplete
ADC START ADC1!()

Do
'Print "CPUTemp "; Pin(temp)
'Pause 1000
Loop

Sub ADCComplete
Print "ADCOutput "; Math(MEAN ADC1!())
ADC START ADC1!()
Pause 1000
Print "CPUTemp "; Pin(temp)
Pause 1000
End Sub


Console output from 5.07.0811
ADCOutput  0.7608791209
CPUTemp  91.65701643
ADCOutput  0.7323076923
CPUTemp  91.18876494
ADCOutput  0.6391941392
CPUTemp  91.18876494
ADCOutput  0.6673992674

> Option List
WebMite MMBasic Version 5.07.08b11
OPTION AUTORUN ON
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 252000
OPTION DISPLAY 41, 140
OPTION WIFI Actiontec1177, **********, PICOE6614103E76
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

> Memory
Program:
  1K ( 1%) Program (17 lines)
 79K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  0K ( 0%) 0 Variables
  0K ( 0%) General
106K (100%) Free

Now the same code running on the Pico W running 5.07.07 with the ADC introduced


> list
SetPin GP26, AIN
Dim ADC1!(10)
ADC open 166666,1,ADCComplete
ADC START ADC1!()

Do
'Print "CPUTemp "; Pin(temp)
'Pause 1000
Loop

Sub ADCComplete
Print "ADCOutput "; Math(MEAN ADC1!())
ADC START ADC1!()
Pause 1000
Print "CPUTemp "; Pin(temp)
Pause 1000
End Sub
>


Console output

> RUN
ADCOutput  0.7577289377
CPUTemp -0.1202746508
ADCOutput  0.7512087912
CPUTemp  91.65701643
ADCOutput  0.7557509158
CPUTemp  91.65701643
ADCOutput  0.7557509158
CPUTemp  91.65701643

> option list
WebMite MMBasic Version 5.07.07
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 264000
OPTION DISPLAY 41, 80
OPTION WIFI Actiontec1177, **********
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

> memory
Program:
  1K ( 1%) Program (18 lines)
 79K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  1K ( 1%) 4 Variables
  0K ( 0%) General
105K (99%) Free

To prove a point to myself :) (this is where the inadvertent power cycle occurred)
Pico W running 5.07.07 with ADC code all commented out

> list
'SetPin GP26, AIN
'Dim ADC1!(10)
'ADC open 166666,1,ADCComplete
'ADC START ADC1!()

Do
Print "CPUTemp "; Pin(temp)
Pause 1000
Loop

'Sub ADCComplete
'Print "ADCOutput "; Math(MEAN ADC1!())
'ADC START ADC1!()
'Pause 1000
'Print "CPUTemp "; Pin(temp)
'Pause 1000
'End Sub


Console output
CPUTemp  34.53033525
CPUTemp  34.99858673
CPUTemp  35.46683822
CPUTemp  34.99858673
CPUTemp  34.99858673
CPUTemp  34.99858673

> option list
WebMite MMBasic Version 5.07.07
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 264000
OPTION DISPLAY 41, 80
OPTION WIFI Actiontec1177, **********
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

> memory
Program:
  1K ( 1%) Program (17 lines)
 79K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  1K ( 0%) 2 Variables
  0K ( 0%) General
105K (100%) Free

And then again but stopping the ADC before reading the pin(temp)

> list
SetPin GP26, AIN
Dim ADC1!(10)
ADC open 166666,1,ADCComplete
ADC START ADC1!()

Do
'Print "CPUTemp "; Pin(temp)
'Pause 1000
Loop

Sub ADCComplete
Print "ADCOutput "; Math(MEAN ADC1!())
ADC CLOSE
Pause 1000
Print "CPUTemp "; Pin(temp)
Pause 1000
ADC OPEN 166666,1,ADCComplete
ADC START ADC1!()
End Sub


On the console

ADCOutput  0.4162637363
CPUTemp  101.4902976
ADCOutput  0.4036630037
CPUTemp  101.4902976
ADCOutput  0.4035164835
CPUTemp  101.4902976
ADCOutput  0.4036630037
CPUTemp  101.4902976

> option list
WebMite MMBasic Version 5.07.07
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 264000
OPTION DISPLAY 41, 80
OPTION WIFI Actiontec1177, **********
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

> memory
Program:
  1K ( 1%) Program (19 lines)
 79K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  1K ( 0%) 3 Variables
  0K ( 0%) General
105K (100%) Free

And then back to the Pico WH running 5.07.0811


> list
SetPin GP26, AIN
Dim ADC1!(10)
ADC open 166666,1,ADCComplete
ADC START ADC1!()

Do
'Print "CPUTemp "; Pin(temp)
'Pause 1000
Loop

Sub ADCComplete
Print "ADCOutput "; Math(MEAN ADC1!())
ADC CLOSE
Pause 1000
Print "CPUTemp "; Pin(temp)
Pause 1000
ADC OPEN 166666,1,ADCComplete
ADC START ADC1!()
End Sub


Console output

ADCOutput  0.7747985348
CPUTemp  94.93477682
ADCOutput  0.2811721612
CPUTemp  95.40302831
ADCOutput  0.2435897436
CPUTemp  95.40302831
ADCOutput  0.2843956044
CPUTemp  95.40302831

> option list
WebMite MMBasic Version 5.07.08b11
OPTION AUTORUN ON
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 252000
OPTION DISPLAY 41, 140
OPTION WIFI Actiontec1177, **********, PICOE6614103E76
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

> memory
Program:
  1K ( 1%) Program (20 lines)
 79K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  1K ( 0%) 2 Variables
  0K ( 0%) General
105K (100%) Free

And if I comment all the ADC items out of the Pico WH running 5.07.0811


> list
'SetPin GP26, AIN
'Dim ADC1!(10)
'ADC open 166666,1,ADCComplete
'ADC START ADC1!()

Do
Print "CPUTemp "; Pin(temp)
Pause 1000
Loop

'Sub ADCComplete
'Print "ADCOutput "; Math(MEAN ADC1!())
'ADC CLOSE
'Pause 1000
'Print "CPUTemp "; Pin(temp)
'Pause 1000
'ADC OPEN 166666,1,ADCComplete
'ADC START ADC1!()
'End Sub


On the console
CPUTemp  90.25226197
CPUTemp  90.25226197
CPUTemp  90.72051346
CPUTemp  90.25226197
CPUTemp  90.72051346
CPUTemp  90.72051346
CPUTemp  90.72051346

> option list
WebMite MMBasic Version 5.07.08b11
OPTION AUTORUN ON
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 252000
OPTION DISPLAY 41, 140
OPTION WIFI Actiontec1177, **********, PICOE6614103E76
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

> memory
Program:
  1K ( 1%) Program (19 lines)
 79K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  1K ( 1%) 1 Variable
  0K ( 0%) General
105K (99%) Free

And now doing a full power cycle on the Pico WH running 5.07.0811

> list
'SetPin GP26, AIN
'Dim ADC1!(10)
'ADC open 166666,1,ADCComplete
'ADC START ADC1!()

Do
Print "CPUTemp "; Pin(temp)
Pause 1000
Loop

'Sub ADCComplete
'Print "ADCOutput "; Math(MEAN ADC1!())
'ADC CLOSE
'Pause 1000
'Print "CPUTemp "; Pin(temp)
'Pause 1000
'ADC OPEN 166666,1,ADCComplete
'ADC START ADC1!()
'End Sub


On the console
CPUTemp  29.8478204
CPUTemp  30.78432337
CPUTemp  30.31607188
CPUTemp  30.78432337
CPUTemp  30.78432337

> option list
WebMite MMBasic Version 5.07.08b11
OPTION AUTORUN ON
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 252000
OPTION DISPLAY 41, 140
OPTION WIFI Actiontec1177, **********, PICOE6614103E76
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

> memory
Program:
  1K ( 1%) Program (19 lines)
 79K (99%) Free

Saved Variables:
 16K (100%) Free

RAM:
  1K ( 1%) 4 Variables
  0K ( 0%) General
105K (99%) Free

Decided to hone in further given the reset option


> list
SetPin GP26, AIN
Dim ADC1!(10)
ADC open 166666,1,ADCComplete
'ADC START ADC1!()

Do
Print "CPUTemp "; Pin(temp)
Pause 1000
Loop

Sub ADCComplete
Print "ADCOutput "; Math(MEAN ADC1!())
ADC CLOSE
Pause 1000
Print "CPUTemp "; Pin(temp)
Pause 1000
ADC OPEN 166666,1,ADCComplete
ADC START ADC1!()
End Sub


Console output on Pico WH running 5.07.0811

CPUTemp  32.18907782
CPUTemp  32.65732931
CPUTemp  32.65732931
CPUTemp  32.65732931
CPUTemp  32.18907782

And with the ADC START ADC1!()active


> list
SetPin GP26, AIN
Dim ADC1!(10)
ADC open 166666,1,ADCComplete
ADC START ADC1!()

Do
Print "CPUTemp "; Pin(temp)
Pause 1000
Loop

Sub ADCComplete
Print "ADCOutput "; Math(MEAN ADC1!())
ADC CLOSE
Pause 1000
Print "CPUTemp "; Pin(temp)
Pause 1000
ADC OPEN 166666,1,ADCComplete
ADC START ADC1!()
End Sub


On console

CPUTemp  91.18876494
ADCOutput  0.2315750916
CPUTemp  98.21253722
ADCOutput  0.2841025641
CPUTemp  98.21253722
ADCOutput  0.2888644689

I had a glipsie when transferring the .bas from the one to the other with TFTP which introduced a power cycle, which then got me thinking and produced the later sets of outputs.

So it looks like the ADC hardware settings are remembered and you have to do a power cycle/reset to clear them...?

But the pin(temp) definitely gives strange values when the ADC is configured on both the 5.07.07 and the 5.07.0811 firmware versions.I also tried doing a reset to the ADC CLOSE included code run and it still gives the strange temperature values.

With the last two runs it is clearly the ADC START ADC1!() which triggers the strange pin(temp) readings. ADC CLOSE does not make pin(temp) work correctly, even through a reset.

Hope this helps.
Cheers Carl                                                        
Retirement is tough on Hobbies without a day job
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 12:25am 24 Aug 2023
Copy link to clipboard 
Print this post

I can confirm that there seems to be a problem.
DIM ADC1!(1000)
ADC OPEN 166666,2,ADCComplete
'ADC START ADC1!()
DO
n = n + 1
PRINT n;"  CPUTemp "; INT(PIN(temp))
PAUSE 1000
IF n = 10 THEN ADC START ADC1!()
LOOP UNTIL n > 40

SUB ADCComplete
ADC CLOSE
k = k + 1
IF k < 50 THEN
ADC OPEN 166666,2,ADCComplete
ADC START ADC1!()
PRINT ".";
ENDIF
END SUB


Run after a reset:
1  CPUTemp  27
2  CPUTemp  27
3  CPUTemp  27
4  CPUTemp  27
5  CPUTemp  27
6  CPUTemp  27
7  CPUTemp  27
8  CPUTemp  27
9  CPUTemp  27
10  CPUTemp  27
11  CPUTemp  84
................................................. 12  CPUTemp  95
13  CPUTemp  86
14  CPUTemp  86
15  CPUTemp  86
16  CPUTemp  86
17  CPUTemp  86
18  CPUTemp  86
19  CPUTemp  86
20  CPUTemp  86
21  CPUTemp  86
22  CPUTemp  86
23  CPUTemp  86


The reported temperature then stay high until the next reset.

Same on a standard picomite

Jim
VK7JH
MMedit   MMBasic Help
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1721
Posted: 12:49am 24 Aug 2023
Copy link to clipboard 
Print this post

Yes, also on b9, both WebMite and standard.
No program needed, same thing happens at the command prompt.
Only CPU Restart returns it to normal.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5867
Posted: 06:06am 24 Aug 2023
Copy link to clipboard 
Print this post

It also does bad things to AIN, not just ADC command.
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8516
Posted: 09:34am 24 Aug 2023
Copy link to clipboard 
Print this post

Pin(temp) bug fixed in b12 - see main betas thread

Please stop posting on this thread and use the main V5.07.08 betas thread for any issues for all variants
 
     Page 5 of 5    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024