adc values to axe33

rob nash

Senior Member
hello again am in a fix been trying to read the values of five ldr on the adc 0 to 5 and send the via serout to the axe 33 and am not sure if it hardware setup or my code could someone help please,

main:
for b0 = 0 to 63
readadc 0,b1
readadc 1,b2
readadc 2,b3
readadc 3,b4
readadc5,b5
pause 10
serout lcd,n2400,(254,128,"lft" ,#b1, " rgt",#b2," ")
serout lcd,n2400,(254,192,"top" ,#b3, " bot",#b4," ")
pause 10
next b0
goto main

i,ve set up the LDR's as the manual says.

the LDRS are set on another board and when i connect that board to the picaxe main board the the sreen apppears to to be reseting.
HELP PLEASE
rob,
 

eclectic

Moderator
@Rob.

Is this your FULL program?
If so, it needs a
symbol command,
longer (1000+) pauses,
and a few other bits of tidying.

2. What EXACTLY are you seeing?

3. Please post your circuit, and a couple of
high-res photo's.

Ec
 

HAZELEB

Member
Serout should have the output pin you are using as below.

serout 7,n2400,(254,128,"lft" ,#b1, " rgt",#b2," ")
serout 7,n2400,(254,192,"top" ,#b3, " bot",#b4," ")

Ted.
 

westaust55

Moderator
Serout should have the output pin you are using as below.

serout 7,n2400,(254,128,"lft" ,#b1, " rgt",#b2," ")
serout 7,n2400,(254,192,"top" ,#b3, " bot",#b4," ")

Ted.
@HAZELEB,
That is what eclectic meant by a need for SYMBOL statements

that is:
SYMBOL LCD = 7 ; replace 7 with what ever output pin number the LCD is attached to.

@Rob,
as eclectic states, what are you seeing?
- nothing,
- values you do not think are right?
- other ?


what LDR are you using - different models have different resistance ranges.
can you give us a link.

which PICAXE chip are you using - if it is an X2 part, have you set up the ADC channels?

we need more information to work with. :confused::confused: :confused:
 

rob nash

Senior Member
hello
this is this full program as it is for now the ldrs are the miniature from tech s.


let dirsB = %11111111
let adcsetup = 3 ' change to %00001111 on 3V parts

symbol lcd = b.7
init: pause 1000
high d.7
serout Lcd,N2400,(254,128,"project picaxe ")
serout Lcd,N2400,(254,192," light 40x2 ")
pause 1000
serout Lcd,N2400,(254,1)
low d.7
goto main

main:

for b0 = 0 to 63
readadc 0,b1
readadc 1,b2
readadc 2,b3
readadc 3,b4
pause 10
serout lcd,n2400,(254,128,"lft" ,#b1, " rgt",#b2," ")
serout lcd,n2400,(254,192,"top" ,#b3, " bot",#b4," ")
next b0
goto main

with lcd and ldr connected this program down loads ( am thinking it not a reset issue)
what i see on the screen is the init display fine but when it comes to the readings the bottom line flips between message 6 and scrambled text
the top line gives the left and right valuse but jumbled dec.points are added the value that are displayed change from hundreds and thousands to scrambled characters.
cheers rob.
 

Dippy

Moderator
What is "message 6" ?

Does it help if you have a brief pause between the two Serout lcd .. lines ?

Which PICAXE as asked before?

What Power supply?

What is your circuit like?
Nice and neat or hairy old breadboard with dodgy wires?
 

rob nash

Senior Member
@dippy


What is "message 6" ?
the bottom line "this is message 6" appears thats it,

Which PICAXE as asked before?
it,s a picaxe 40x2 which is mentioned in the init part of the program
5.5 v 4 AA battries.

What is your circuit like?
!!!CRAP!!!with a complete lack of understanding of the basics theory
so its back to the breadboard this afternoon

cheers rob
 

MartinM57

Moderator
What is "message 6" ?
the bottom line "this is message 6" appears thats it,

..with a complete lack of understanding of the basics theory
so its back to the breadboard this afternoon
Message6 is very clever as it's not in the code you posted.

Simplify, simplify. Remove the loops, put pauses in to give the LCD a chance to keep up and print some slowly çhanging variables rather than rapid readadc's.

(posted by a MJM57 via BlackBerry stranded in a carppy Santa Cruz (Bolivia) hotel, rather than a 5* Miami hotel thanks to American Airlines. Will never use AA again...)
 

Dippy

Moderator
Ah, "message 6", yes I should have spotted that in my CB...

Sort out your circuit first. Tidy it up, decouple the PICAXE, make sure wires aren't excessively long and/or not close to a noisy device. Check for good connections.
No point trying to polish a turd :)
Have you tried pause between Serouts? You didn't reply.

Once we have removed those variables we can investigate further.

Aha, Martin, showing off your blackberry eh?
So, you are miles away from the intended destination - surely that's the job of Ryan Air :)
 

BeanieBots

Moderator
"this is message 6" is the default value of the pre-defined AXE033 message number 6.
It is invoked by sending the decimal value 6 to the display.
As this does not appear anywhere in the code, I would suspect a baud-rate tollerance issue. This might be compounded because the power supply is too high at 4X1.5v (nominal).

Options to try would be to run from a regulated 5v.
(3X1.5 might not be enough for the LCD)

The other option would be to play with CALIBFREQ to make small adjustments to the PICAXE clock speed to try and get the baud-rate better matched for the AXE033 which I have found can be a bit out.
 

Technical

Technical Support
Staff member
Change this:

serout lcd,n2400,(254,128,"lft" ,#b1, " rgt",#b2," ")
serout lcd,n2400,(254,192,"top" ,#b3, " bot",#b4," ")

To this:

bintoascii b1, b20, b21, b22
bintoascii b2, b23, b24, b25
serout lcd,n2400,(254,128,"lft" ,b20,b21,b22, " rgt",b23,b24,b25)
bintoascii b3, b20, b21, b22
bintoascii b4, b23, b24, b25
serout lcd,n2400,(254,192,"top" ,b20,b21,b22, " bot",b23,b24,b25)


There is no need to use calibfreq. On early X2 firmware the # conversion of a variable into three ascii characters could transmit the three bytes back to back marginally too fast for the AXE033 to keep up. Using calibfreq would slow the chip down and appear to resolve it, but it is not really a good solution as it is not a baud rate issue, it is a 'gap between each byte' issue. Using the bintoascii to send each byte individually normally resolves the issue in a better way, and will also give you a neater aligned display when changing between 2 and 3 digit values.
 

rob nash

Senior Member
hello all,
A smile returns
well back on the beadboard and success, made the changes as technical advised made a huge diff. to steady and tidy reading.
the board i made up on strip board give a steady reading brill i'll thought then it dawned on me the the ldr's was'nt connected !!!OOO what!!!.
now for the strip board there was'nt many component on the board
40 dip
for pin connecter for lcd hard wired on b.7
then all other legs wired out to four rows 8 "7 on theadc " output the plan was to A,B,C,D
and two 100 uf caps on v to ground and the download circuit
and thats the lot my plan was to stack a board on top of that one
which went well added an ULN28003A to the top board connected to D
added four pins via resistors 4.7k to connect a axe101 all fine." am thinking "
comes to testing the adc 'well you know about part if you read the whole thread..
I'm thinking this is a poor track layout anyway working fine on breadboard and thank you all for your replies,

could someone explain or point me right direction about decoupling a picaxe
"i hear the words OMG being uttered at the screen".
cheers rob
 

hippy

Technical Support
Staff member
For decoupling, a 100nF capacitor across 0V and +V close to the chip is the usual choice. It cuts down 'transients' on the power supply.
 
Top