New to PICS and Programming SERIN woes

jmumby

Senior Member
I am using the following to try and test the serin connection on an 08. All I get at the moment is PIN 2 going high and low when sending data. If I disconect the pin 3 from the pixace the program goes to neither: What should I use to send data? Telnet?

repeatforever:
SERIN 3,N2400,b0
b1= b0

high 2
pause 250
low 2

if b1="0" then red
if b1="1" then green
if b1="" then neither
goto repeatforever

green:
high 4
pause 250
low 4
goto repeatforever


red:
high 1
pause 250
low 1
goto repeatforever

neither:
high 4
high 1
pause 250
low 4
low 1
goto repeatforever

I have connect the diode and resisters as recommended in the documentation.

Thanks,

Jason
 

ylp88

Senior Member
First of all, try convertng the SERIN line to:

SERIN 3,N2400,#b0

This ensures that the PIC stores the received number as a number and not a a caharcter which the number represents in ASCII. Secondly, you should just use the Programming Editor Terminal to send data to the PICAXE via the serial port. I believe that it is by far the easiest to use and saves you having to configure the port through HyperTerminal.

ylp88
 

jmumby

Senior Member
Thanks for your reply!

Managed to get my TX's and RX's back to front. I can now get 8 bit's b1~b8 is there anyway to join these all together and store them in b0 as a 8 bit number e.g 00001111 assumming that b1=0,b2=0,b3=0,b4=0,b5=1,b6=1,b7=1,b8=1?

Ultimatly the result i'd like is LET PINS =b0
Thanks again,

Jason
 

ylp88

Senior Member
Well...

set0:
If b0 <> 1 Then set1
bit0 = 1
set1:
If b1 <> 1 Then set2
bit1 = 1
set2:
If b2 <> 1 Then set3
bit2 = 1
set3:
If b3 <> 1 Then set4
bit3 = 1
set4:
If b4 <> 1 Then set5
bit4 = 1
set5:
If b5 <> 1 Then set6
bit5 = 1
set6:
If b6 <> 1 Then set7
bit6 = 1
set7:
If b7 <> 1 Then setend
bit7 = 1
setend:
... [Rest of Program] ...
 

jmumby

Senior Member
Is there anyway to post 8 bits in the memory location all at once? I thought b0=%00001111 would be ok. Your code works a charm but I am using an 08 and it soaks up few lines. Basically I'd like to do a IF b0 = b1 then.
 

hippy

Technical Support
Staff member
You can use 'b0=%00001111' - It's not clear what problem you are having trying to use that.

A shorter way to do the bit assignments from byte variables would be ...

- bit0 = b8
- bit1 = b7
- bit2 = b6
- bit3 = b5
- bit4 = b4
- bit5 = b3
- bit6 = b2
- bit7 = b1

The value will then be stored in b0, for b1=0, b2=0, b3=0, b4=0, b5=1, b6=1, b7=1, b8=1 this will be %00001111.
 
Top