Picaxe and C#.net

marcos.placona

Senior Member
So I've created this very basic C# application that simply sends data to a Picaxe 08m and activate some outputs according to what's received

I've been a long time outside of the "Picaxe Land" due to a number of factors, and am trying to catch up again.

What my Picaxe code is does is:

Code:
Do
	SerIn 1,2400, ("data"),b1
	if b1 = 3 or b1 = "3" then
		high 2
	end if
Loop
Pretty standard as you can see, I use "data" as my check point, so I know what's to be read and check for b1's value. In case it's equal 3, I'll set my output 2 to high

On my C# side of things, I have an interface with a button that will send "data3" when clicked.

It's also using a baudrate of 2400 and hooked to COM1 (same port as my picaxe)

Two things I'm finding difficult here is that as far as I could see, there's no way to check on the terminal what my C# application is sending, as whenever I try to open the terminal once my C# application is open, I get an error saying the port is already in use

Another thing is that if I try to serout 1,2400,(b1) right after I serin on the code, I get a lot of gibberish, and I only get this in case I remove the ("data") from my serin

I'm sure I'm doing something stupid here, but could anyone please give me a hand as per why my output 2 never goes high?

Thanks in advance

UPDATE: Just think it's important to mention that I've already scavenged the forum looking for answers, and couldn't find much regarding C#
 

marcos.placona

Senior Member
Hi, thanks for your answer, I've installed the software you mentioned, but I still get access denied when trying to send data from my C# application.

I then tried to send data from the software itself, but nothing happens with my output2 (i.e. it never goes high)

Am I missing anything important here :D?

Thanks
 

hippy

Ex-Staff (retired)
Welcome back.

Probably a simple case of 'forgotten what you've learned' and changing from one language to another, and ... I think you left an N out ...

SerIn 1, N2400, ( "data" ), b1
 

marcos.placona

Senior Member
Probably a simple case of 'forgotten what you've learned' and changing from one language to another
Spot on!

I think you left an N out ...
Spot on again....

... However I still can't get the output to go high when I pass "data3".. I even tried via picaxe terminal to see if it would make any difference, but it seems like the "validation" makes it all more impossible to go through and validate that the value passed was == "data3"

One thing I don't understand though:

Shouldn't a code like this:

Code:
Do
	SerIn 3,N2400, ("data"),b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
	serout 0,N2400,(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13)
	if b1 = 3 or b1 = "3" then
		high 0
	end if
Loop
output what's been passed on the picaxe terminal? It seems to not be receiving any data at all.
 
Last edited:

hippy

Ex-Staff (retired)
"data3" is ascii character "3" ( $33 ) and then you test for numeric value 3. Try ...

If b1 = "1" Or b1 = "3" Then
 

marcos.placona

Senior Member
OK, I've modified it slightly, but still no joy.

Code:
Do
	SerIn 3,N2400,("data"), b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13
	if b0 = $33 or b0 = "3" or b0 = 3 or b0 = 1 then
		high 2
	end if
Loop
Trying to send "data3" from picaxe terminal results in nothing... Any other suggestion?
 

hippy

Ex-Staff (retired)
Try ...

SerIn 3,N2400,("data"), b0

Otherwise the PICAXE, having received "data3" will be waiting for data which you haven't sent. Alternatively, send 12 extra bytes of data after "data3".

Added : Also, if this is an 08M you need to have a diode clamp from pin 3 to +V.
 
Top