Labview and PICAXE

kamilan

Member
Hello,

Aim: To output a count from the PICAXE to LABVIEW via serial PORT.

I am using a PICAXE 08M. Using the "PULSIN" function at 8 MHz. I'm storing the count of the pulse in "w1"

Not sure what to do in terms of setting up serial communication with LabVIEW. I'm using LabVIEW 7 and a computer that has a serial port. Can anyone point me in the right direction. Websites or some code would be great :p

Can I just use "SEROUT" with appropriate baud rate to talk to LabVIEW? Do I need to convert w1 from count to character?

Thanks

K
 

hippy

Ex-Staff (retired)
I've not used LabVIEW but there are official support forums and user groups which may be able to help ( http://www.ni.com/labview ) and Google shows a number of LabVIEW related resources.

It really depends on what LabVIEW is expecting. My guess would be that it expects raw numeric data -

SEROUT pin, baud, ( #w1, CR, LF )
 

hax

New Member
Go to your functions palette, then input then instrument assistant.

Select the com port you are using.


then select add step

then read and parse

then click "run this step".



If your picaxe is already sending numbers, it will show up on screen. Hit ok and you have set up your vi.
 

kamilan

Member
OK,

Hey there guys.

Thanks for the input. I'm gonna try your advice today.

Sadly, this is the 08M there is no "sertxd"

thanks anyway.

Will update on progress. :)
 

Andrew Cowan

Senior Member
While there is no serial input on the serial in pin, there is the plain serin command. Connect the download cable to a different pin (including the required resistors), and you can use this.

Remember the diode if you use input 3.

A
 

kamilan

Member
Got some bits working

Hello,

I've got LabVIEW reading some information in from the serial port.

I'm using pin0 as that has the 3.5mm jack to RS232.

At the moment, I can send the character "A" but nothing else.

I would like to send a number.

pulsin stores the count is w1. How do I output w1?

Cheers

K
 

kamilan

Member
Got it working with with the TERMINAL

Hello,

Here is my code, and it works so that when I give a high to PIN3 it will time a pulse on PIN1. Then output the count via serial communication to the PICAXE Terminal.

The code works for LabVIEW as well.

'---TIMING CODE----------------------------------------------------------

Init:
Setfreq m8 ' set clock to 8Mhz
Symbol PulseCount = w1 ' Assigning a name to varible w1
Input 1,3 ' make pin 1 & 3 an input
Output 0,2,4 ' set outputs to low

'--------------------------------------------------------------------------

Main:
if pin3 = 1 then Pulse ' Recieves Signal from PICAXE1 to start timing the PULSE
goto main ' else loop back around

'------------------------------------------------------------------------------

Pulse: ' Will meaure the length of a pulse fed into pin1
pulsin 1,1,PulseCount ' record the length of a pulse on pin1 into w1
gosub CountOut ' Will output number off counts to computer.
goto main ' each count is a function of the clock frequency.

'--------------------------------------------------------------------------

CountOut:
PAUSE 1000
sertxd("The value of w1 is ",#w1,13,10) ' will output code, then use a new line
return
 

kamilan

Member
Silent Screamer

Hey Dude,

You are so right! I was looking at the manual and read it wrong. THANKS FOR THE HELP!!!

I was watching saturday morning cartoons!!! Much better than PICAXE :p
 

kamilan

Member
another question?

Is it possible to set up duplex serial communication?

Whilst sertxd works fine i would now like to send information.

At present i can write information via PIN1 using serin. I can also read information from PIN2 using serout. I am using a home brew serial cable.

However, when i try and set up serial comms with LabView, the write works, but the READ does not.

Any suggestions?

K
 

hax

New Member
They should both work fine.

Post your code.

Duplex means send and receive at the same time. Technically not possible on an 08M but you can poll the picaxe, and have it send back a variable. No problems there. Just a terminology point.
 
Last edited:

kamilan

Member
Here is my code

Hello,

Thats for clearing up the term "duplex" for me.


Intial:
setfreq m8

main:
serin 1,N4800_8,("GO")
gosub Hello
goto main

Hello:
pause 1000
serout 2,N4800_8,("HELLO")
return
end

I think I'm havng problems on the LabVIEW end more so than the PICAXE when. This is my code.

Cheers

K
 
Top