Read ADC Problem

#1
I'm a pleb so i use the visual programming BASIC but if you guys could have a look it would be great.
I am experiancing a problem where even though the ADC variable would be <65 the program still runs, the only way that I can get the program to physically work is if i have the programming cord connected to the picaxe and my laptop whilst im using it.
Itteration 7.PNG
 

rq3

Senior Member
#2
I'm a pleb so i use the visual programming BASIC but if you guys could have a look it would be great.
I am experiancing a problem where even though the ADC variable would be <65 the program still runs, the only way that I can get the program to physically work is if i have the programming cord connected to the picaxe and my laptop whilst im using it.
View attachment 22253
I've never dreamed of trying to program that way, and I'm really bad at code. But. I'll take a shot. The value of C.4 determines what the entire program will do, and it doesn't even begin to get an ADC reading at start-up. It's in a nebulous state until you tell it to do something (go high, go low, or be an input and take an ADC reading).

Hippy, white telephone please. Paging hippy. I know, totally worthless attempt at humor, hippy will be along very rapidly, as will others, and you will be on your way!

Also, make sure that your grounds are electrically common (connected together intimately). The ADC function is very sensitive, and if it is only getting electrical ground through the programming jack of the AXE027 (or wherever), the ADC results will vary wildly.
 
Last edited:

hippy

Technical Support
Staff member
#3
I am experiancing a problem where even though the ADC variable would be <65 the program still runs, the only way that I can get the program to physically work is if i have the programming cord connected to the picaxe and my laptop whilst im using it.
That seems to suggest that the download cable is affecting the ADC readings. That shouldn't happen when using an AXE027 but there may be other issues.

The best approach to resolving this issue would be to write a Basic program which can be started with or without the AXE027 plugged in, then report what the ADC readings were in both cases once the AXE027 is connected-

Code:
Gosub ReadTheAdc
b1 = b0 ; Min reading
b2 = b0 ; Initial reading
b3 = b0 ; Max reading

For b4 = 1 To 20
  Gosub ReadTheAdc
  b1 = b1 Max b0 ; Max means lowest
  b3 = b3 Min b0 ; Min means highest
  Pause 250  
Next

Do
  SerTxd( #b1, TAB, #b2, TAB, #b3, CR, LF )
  Pause 1000
Loop

ReadTheAdc:
  ReadAdc C.4, b0
  Return
Download that and run it. Note the output.

Turn the PICAXE power off. Disconnect the AXE027. Turn power back on. After 10 seconds plug the AXE027 back in. Note the output again.

Let us know what readings you get.

If you can let us know which PICAXE you are using, what your full circuit is, that may help diagnose things.
 
Top