Serrxd - Oh god nothing is happening

Trying my hand at making a computer interface for a PICAXE28x2. Plans are for it to send serial data through the programming cable and for that data to be interpreted and acted upon by the picaxe. To test how this serial communications works, i've set up the following code on the picaxe.

 


interface:


    serrxd b0
    if b0 = %00000001 then
    sertxd ("Recieved")
    end if

    goto interface

 


the sertxd line i have tried with many different forms of feedback, and LED indicator if a message is recieved - nothing works:

In the terminal i have tried typing: 1, %00000001, and other such nonesense but fail to recieve the confirmation message.

I know the picaxe can send messages back with the sertxd command, this isn't a problem.

So, LMR, bestow upon me your wisdom!

"1" isn’t 1 in ASCII

Try to change your program to this and see how it works:
interface:
    serrxd b0
    sertxd ("Recieved: ", b0, " and it’s ascii value is ", #b0, “.”, 13, 10)
    goto interface

Then check this out: http://en.wikipedia.org/wiki/ASCII
Sections about control and printable characters have ASCII code tables.

The point is that when you send ‘1’ as text it’s ASCII value is 49. So in your case b0 would have value 49 (not 1 or %00000001). So your program would work as you want it to work if you change “if b0 = %00000001 then” to “if b0 = 49 then”. You might also want to add carriage return and new line characters (ASCII codes 13 and 10) after text “Received” like I have above.

Hope it helps.

 

Just remembered something

Just remembered something. You can also use serrxd like this:
interface:
    serrxd #b0
    if b0 = %00000001 then
        sertxd (“Recieved”, 13, 10)
    end if
   
    goto interface

Now “serrxd #b0” reads “decimal numbers into variables, rather than raw characters” (like manual 2 states). Just remember to send some other character than number after the number out want (so for example type “1” and enter to terminal output buffer before hitting send).

Thanks for the help,

Thanks for the help, nuumio.

That debugging program will also prove to be very handy in the near future I think.