Why doesn't this work?

RickAlty

Senior Member
I am still fiddling with my LED driver program..... I've moved on to trying to get the ability to select the display from the PC. The code below, used with the terminal in the programming editor, *should* display "12345" if 1 is sent from the terminal, "67890" if 2 is sent. Well, nothing at all happens. It looks like the PICAXE is never getting the serin at all. When I type 1 in the output buffer and press send, I get a string of blocks appear in the input buffer, but no response from the PICAXE board.

What I've checked.... Yes, I am switching the input from the serial download pin to input pin 1 (physical pin 18) after downloading the program. Yes, the protocol in the editor is 2400,N,8,1.

Here's the code... (without the serin parts, if the 'ledhigh' and 'ledlow' subs are just looped, the display flops back and forth betwen "12345" and "67890" just like it should)

main:

serin 1,n2400,b1
b0 = b1
if b0=1 then ledlow
if b0=2 then ledhigh

goto main

ledhigh:

high 3
pause 1
low 3
pause 1
high 4
high 3
pause 1
low 3
low 4
gosub six
gosub seven
gosub eight
gosub nine
gosub zero
high 3
pause 1
low 3
goto main

ledlow:

high 3
pause 1
low 3
pause 1
high 4
high 3
pause 1
low 3
low 4
gosub one
gosub two
gosub three
gosub four
gosub five
high 3
pause 1
low 3
goto main

Any ideas?

Richard
 

hippy

Technical Support
Staff member
Try ...

- SERIN 1,N2400,b1
- b0 = b1
- IF b0 = <b>&quot;1&quot; </b> THEN ledlow
- IF b0 = <b>&quot;2&quot; </b> THEN ledhigh

Edited by - hippy on 4/9/2005 10:21:28 AM
 

RickAlty

Senior Member
Thanks, Hippy, but still no joy.

I commented out all but the serin line, so now it should go to display &quot;12345&quot; then &quot;67890&quot; once as soon as it gets anything from the serial input, but still nothing. Commenting out the serin line sends it back to looping through the two displays just as I'd expect.

Am I doing something wrong in the terminal on the PC? All I'm doing is typing a single digit in the output buffer then clicking SEND. When I do, a series of characters appears in the inout buffer window. Is that a sign that the PICAXE got something and echoe'd it?

main:

SERIN 1,N2400,b1
'b0 = b1
'IF b0=&quot;1&quot; THEN ledlow
'IF b0=&quot;2&quot; THEN ledhigh

'goto main

'ledhigh:

high 3
pause 1
low 3
pause 1
high 4
high 3
pause 1
low 3
low 4
gosub six
gosub seven
gosub eight
gosub nine
gosub zero
high 3
pause 1
low 3
'goto main

'ledlow:

high 3
pause 1
low 3
pause 1
high 4
high 3
pause 1
low 3
low 4
gosub one
gosub two
gosub three
gosub four
gosub five
high 3
pause 1
low 3
goto main
 

hippy

Technical Support
Staff member
Are you entirely sure you aren't sending your serial data into the Download Serial In pin and looking at the Download Serial Out ?

Unless you are reading your serial back from a pin being affected by the code, you shouldn't see anything echoed back to the terminal window.

Edited by - hippy on 4/9/2005 7:30:17 PM
 

RickAlty

Senior Member
Thanks for the help, hippy. In the end the problem was hardware - there was a solder whisker on the switch that selects between PROG and RUN on my PCB :-(

Richard
 
Top