PDA

View Full Version : Getting Parallax PLX-DAQ to work with HSEROUT



dbachman
- 23rd January 2011, 20:12
Does anyone know how to use HSEROUT to talk to PLX-DAQ? I am getting a RX from PLX-DAQ
but apparently my format is wrong or maybe it just doesn't work with a PIC.

Thanks, Don

ScaleRobotics
- 23rd January 2011, 20:51
Hi Don,

I have not tried using that, but others have been successful. Here is one thread that talks a little about it.

http://www.picbasic.co.uk/forum/showthread.php?t=13564

dbachman
- 23rd January 2011, 23:22
Hi Don,

I have not tried using that, but others have been successful. Here is one thread that talks a little about it.

http://www.picbasic.co.uk/forum/showthread.php?t=13564

Yea I tried that but couldn't get it to work.

Thanks

ScaleRobotics
- 23rd January 2011, 23:29
Yea I tried that but couldn't get it to work.

Hey Don,

What stage of not working is it at? Do you have some code?

Have you tested your hserout, to be sure you have the right baud rate, etc?

dbachman
- 24th January 2011, 00:18
Hey Don,

What stage of not working is it at? Do you have some code?

Have you tested your hserout, to be sure you have the right baud rate, etc?

There really is no code just the defines and HSEROUT. Bare minimum. It connects and I can see the little green box with the "R" in it flash red when I reset the pic. I can receive no problem with hyperterminal and the terminal in Microcode Studio. I have used Debug and Hserout2 with those two with no problems. I think it might be a format issue.

ScaleRobotics
- 24th January 2011, 01:31
Well, this is from their help file. You probably already saw it though. Hserout should work, as long as it is set up correctly.

(8 bits, no parity, 1 stop bit)
<table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td valign="top"> PLX-DAQ Directives
PLX-DAQ analyzes incoming data strings from the controller for action. Strings begin with a directive informing PLX-DAQ of what action to take.


All directives are in CAPITAL letters, and some are followed by comma-separated data. Each string MUST end in a carriage return (CR).
Strings not beginning with directives will be ignored.
Note that the BASIC Stamp's DEBUG instruction is used in the following discussion.

<table border="1" width="800"> <tbody> <tr> <td align="middle" width="304">Control and Data Directives</td> <td align="middle" width="480">BASIC Stamp Example Usage</td></tr> <tr> <td width="304">DATA, value1, value2,...
Stores the data into the next row from column A on.</td> <td width="480">Up to 26 comma values may be sent. The 1st value will be placed in column A, the 26th in column Z.
DEBUG "DATA,", DEC Val1, ",", DEC Val2, CR Special: The strings TIME, TIMER and DATE in value positions 1 and 2 will cause PLX-DAQ to replace those strings with the current time (TIME) or the time in seconds since opening or the last timer reset (TIMER), and date when using the DATA directive.
DEBUG "DATA, TIME, TIMER,", DEC Val1,",",DEC Val2,CR
</td></tr> <tr> <td width="304">LABEL, label 1, label 2, label 3,...
Labels the columns from A up to Z. Row 1 is used for labels, up to 26 labels may be sent.
</td> <td width="480">DEBUG "Time, Timer, Value 1, Value 2", CR</td></tr> <tr> <td width="304">CLEARDATA
Clears columns A-J of data from Row 2 on (labels remain in Row 1), or the number of columns to which data was being posted.</td> <td width="480">DEBUG "CLEARDATA",CR</td></tr> <tr> <td width="304">RESETTIMER
Resets the when using the TIMER directive to place the time in seconds into the cell.</td> <td width="480">DEBUG "RESETTIMER",CR</td></tr> <tr> <td width="304">MSG, message string
Places a message in the PLX-DAQ Controller Message box. Do not use commas in the message string.
</td> <td width="480">DEBUG "MSG, Starting data run.",CR</td></tr></tbody></table>
<table border="1" width="800"> <tbody> <tr> <td align="middle" width="304">Interactive Directives</td> <td align="middle" width="480">BASIC Stamp Example Usage</td></tr> <tr> <td width="304">ROW,GET
Retrieves the last row number data was placed into using the DATA directive.
</td> <td width="480">DEBUG "ROW,GET",CR ' Request row
DEBUGIN DEC row ' Accept row value into variable
or
SEROUT 16,84,["ROW,GET",CR] ' Request Row
SERIN 16,84,500,Timeout,[DEC row] ' Accept row value with timeout
Timeout:</td></tr> <tr> <td width="304">ROW,SET,Value
Sets the row number to use for next DATA</td> <td width="480">DEBUG "ROW,SET,2",CR ' Send next data to row 2</td></tr> <tr> <td width="304">CELL,GET,cellnum
Retrieves the value in a specified cell.</td> <td width="480">DEBUG "CELL,GET,A4",CR ' Request cell value
DEBUGIN DEC cellval ' Accept cell value into variable
or
SEROUT 16,84,["CELL,GET,A4",CR] ' Request cell
SERIN 16,84,500,Timeout,[DEC cellval] ' Accept cell value with timeout
Timeout: Note: variables and constants may be used for cells in the A-F range by using hexadecimal.
Cell CON $A4
DEBUG "CELL,GET,", HEX CELL,CR
</td></tr> <tr> <td width="304">CELL,SET,cellnum,cellvalue
Sets the specified cell value or text</td> <td width="480">DEBUG "CELL,SET,B4,Hello!",CR
DEBUG "CELL,SET,B5,", DEC x, CR
Note: variables and constants may be used for cells in the A-F range by using hexadecimal. See CELL,GET.</td></tr> <tr> <td width="304">DOWNLOAD,GET
STORED,GET
USER1,GET
USER2,GET
Reads the status of one of the four checkboxes
on the PLX-DAQ interface.
0 for unchecked
1 for checked.</td> <td width="480">DEBUG "USER1,GET",CR ' Request checkbox value
DEBUGIN DEC check1 ' Accept value into variable
IF check1 = 1 Then ...
or
SEROUT 16,84,["USER1,GET",CR] ' Request cell
SERIN 16,84,500,Timeout,[DEC check1] ' Accept cell value with timeout
Timeout:</td></tr> <tr> <td width="304">DOWNLOAD,SET, 0 or 1
STORED,SET, 0 or 1
USER1,SET, 0 or 1
USER2,SET, 0 or 1
Sets the status of one of the four checkboxes
on the PLX-DAQ interface.
0 for unchecked
1 for checked.</td> <td width="480">DEBUG "USER1,SET,1",CR ' Sets checkbox USER1 to 1</td></tr> <tr> <td width="304">DOWNLOAD,LABEL,text
STORED,LABEL,text
USER1,LABEL,text
USER2,LABEL,text
Sets the text of the checkboxes</td> <td width="480">DEBUG "USER2,LABEL,Check me!",CR ' Sets USER2 checkbox label.</td></tr></tbody></table></td></tr></tbody></table>

BASIC Stamp Code
BASIC Stamp code is used to illustrate using the Simple Data with Plotting sheet of PLX-DAQ.


This program sends the value of variable X and the BASIC Stamp SIN value of X.
SEROUT sPin,Baud,["DATA,TIME,TIMER,", DEC X, ",", SDEC SIN X, CR]
The current row is read, and when exceed, will reset the row back to 2.
SEROUT sPin,Baud,["ROW,GET",CR] ' Request Row
SERIN sPin, Baud,200,TimeOut,[DEC Row] ' Accept returning data with timeout
IF Row >= 300 THEN SEROUT sPin,Baud,["ROW,SET,2",CR] ' If Row is or exceeds 300, set row back to 2

Note that SEROUT 16,84 (sPin and Baud values) is used to send data. This is equivalent to DEBUG but prevent the DEBUG window opening.
SERIN 16,84 is used, which is equivalent to DEBUGIN, but provides for timeouts to be used so that the program does not lock up if there is a problem.
When using the DATA directive to send multiple values, a combination of strings and values is needed to force commas between values.

dbachman
- 24th January 2011, 01:44
Well, this is from their help file. You probably already saw it though. Hserout should work, as long as it is set up correctly.

(8 bits, no parity, 1 stop bit)
<table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td valign="top"> PLX-DAQ Directives
PLX-DAQ analyzes incoming data strings from the controller for action. Strings begin with a directive informing PLX-DAQ of what action to take.


All directives are in CAPITAL letters, and some are followed by comma-separated data. Each string MUST end in a carriage return (CR).
Strings not beginning with directives will be ignored.
Note that the BASIC Stamp's DEBUG instruction is used in the following discussion.

<table border="1" width="800"> <tbody> <tr> <td align="middle" width="304">Control and Data Directives</td> <td align="middle" width="480">BASIC Stamp Example Usage</td></tr> <tr> <td width="304">DATA, value1, value2,...
Stores the data into the next row from column A on.</td> <td width="480">Up to 26 comma values may be sent. The 1st value will be placed in column A, the 26th in column Z.
DEBUG "DATA,", DEC Val1, ",", DEC Val2, CR Special: The strings TIME, TIMER and DATE in value positions 1 and 2 will cause PLX-DAQ to replace those strings with the current time (TIME) or the time in seconds since opening or the last timer reset (TIMER), and date when using the DATA directive.
DEBUG "DATA, TIME, TIMER,", DEC Val1,",",DEC Val2,CR
</td></tr> <tr> <td width="304">LABEL, label 1, label 2, label 3,...
Labels the columns from A up to Z. Row 1 is used for labels, up to 26 labels may be sent.
</td> <td width="480">DEBUG "Time, Timer, Value 1, Value 2", CR</td></tr> <tr> <td width="304">CLEARDATA
Clears columns A-J of data from Row 2 on (labels remain in Row 1), or the number of columns to which data was being posted.</td> <td width="480">DEBUG "CLEARDATA",CR</td></tr> <tr> <td width="304">RESETTIMER
Resets the when using the TIMER directive to place the time in seconds into the cell.</td> <td width="480">DEBUG "RESETTIMER",CR</td></tr> <tr> <td width="304">MSG, message string
Places a message in the PLX-DAQ Controller Message box. Do not use commas in the message string.
</td> <td width="480">DEBUG "MSG, Starting data run.",CR</td></tr></tbody></table>
<table border="1" width="800"> <tbody> <tr> <td align="middle" width="304">Interactive Directives</td> <td align="middle" width="480">BASIC Stamp Example Usage</td></tr> <tr> <td width="304">ROW,GET
Retrieves the last row number data was placed into using the DATA directive.
</td> <td width="480">DEBUG "ROW,GET",CR ' Request row
DEBUGIN DEC row ' Accept row value into variable
or
SEROUT 16,84,["ROW,GET",CR] ' Request Row
SERIN 16,84,500,Timeout,[DEC row] ' Accept row value with timeout
Timeout:</td></tr> <tr> <td width="304">ROW,SET,Value
Sets the row number to use for next DATA</td> <td width="480">DEBUG "ROW,SET,2",CR ' Send next data to row 2</td></tr> <tr> <td width="304">CELL,GET,cellnum
Retrieves the value in a specified cell.</td> <td width="480">DEBUG "CELL,GET,A4",CR ' Request cell value
DEBUGIN DEC cellval ' Accept cell value into variable
or
SEROUT 16,84,["CELL,GET,A4",CR] ' Request cell
SERIN 16,84,500,Timeout,[DEC cellval] ' Accept cell value with timeout
Timeout: Note: variables and constants may be used for cells in the A-F range by using hexadecimal.
Cell CON $A4
DEBUG "CELL,GET,", HEX CELL,CR
</td></tr> <tr> <td width="304">CELL,SET,cellnum,cellvalue
Sets the specified cell value or text</td> <td width="480">DEBUG "CELL,SET,B4,Hello!",CR
DEBUG "CELL,SET,B5,", DEC x, CR
Note: variables and constants may be used for cells in the A-F range by using hexadecimal. See CELL,GET.</td></tr> <tr> <td width="304">DOWNLOAD,GET
STORED,GET
USER1,GET
USER2,GET
Reads the status of one of the four checkboxes
on the PLX-DAQ interface.
0 for unchecked
1 for checked.</td> <td width="480">DEBUG "USER1,GET",CR ' Request checkbox value
DEBUGIN DEC check1 ' Accept value into variable
IF check1 = 1 Then ...
or
SEROUT 16,84,["USER1,GET",CR] ' Request cell
SERIN 16,84,500,Timeout,[DEC check1] ' Accept cell value with timeout
Timeout:</td></tr> <tr> <td width="304">DOWNLOAD,SET, 0 or 1
STORED,SET, 0 or 1
USER1,SET, 0 or 1
USER2,SET, 0 or 1
Sets the status of one of the four checkboxes
on the PLX-DAQ interface.
0 for unchecked
1 for checked.</td> <td width="480">DEBUG "USER1,SET,1",CR ' Sets checkbox USER1 to 1</td></tr> <tr> <td width="304">DOWNLOAD,LABEL,text
STORED,LABEL,text
USER1,LABEL,text
USER2,LABEL,text
Sets the text of the checkboxes</td> <td width="480">DEBUG "USER2,LABEL,Check me!",CR ' Sets USER2 checkbox label.</td></tr></tbody></table></td></tr></tbody></table>

BASIC Stamp Code
BASIC Stamp code is used to illustrate using the Simple Data with Plotting sheet of PLX-DAQ.


This program sends the value of variable X and the BASIC Stamp SIN value of X.
SEROUT sPin,Baud,["DATA,TIME,TIMER,", DEC X, ",", SDEC SIN X, CR]
The current row is read, and when exceed, will reset the row back to 2.
SEROUT sPin,Baud,["ROW,GET",CR] ' Request Row
SERIN sPin, Baud,200,TimeOut,[DEC Row] ' Accept returning data with timeout
IF Row >= 300 THEN SEROUT sPin,Baud,["ROW,SET,2",CR] ' If Row is or exceeds 300, set row back to 2

Note that SEROUT 16,84 (sPin and Baud values) is used to send data. This is equivalent to DEBUG but prevent the DEBUG window opening.
SERIN 16,84 is used, which is equivalent to DEBUGIN, but provides for timeouts to be used so that the program does not lock up if there is a problem.
When using the DATA directive to send multiple values, a combination of strings and values is needed to force commas between values.


I seen that and tried a 13 for the carriage return.......

HSEROUT ("HELLO",13] is this right?

mackrackit
- 24th January 2011, 02:11
Each string MUST end in a carriage return (CR)
Maybe they really mean CR ??

mister_e
- 24th January 2011, 02:17
Yeah but typewriter are so hard to find theses days ;)

Not sure they have some SMD one?

dbachman
- 24th January 2011, 02:50
Maybe they really mean CR ??

so like this huh?

HSEROUT ["hello",cr]

Hmmmm..... Maybe

SMD?? I think I have one of those in the garage......

I'll go get it and try it....be right back

ScaleRobotics
- 24th January 2011, 15:14
so like this huh?

HSEROUT ["hello",cr]


I don't think hello is a directive.


PLX-DAQ Directives
PLX-DAQ analyzes incoming data strings from the controller for action. Strings begin with a directive informing PLX-DAQ of what action to take.


All directives are in CAPITAL letters, and some are followed by comma-separated data. Each string MUST end in a carriage return (CR).
Strings not beginning with directives will be ignored.
Note that the BASIC Stamp's DEBUG instruction is used in the following discussion.


Maybe something like:
HSEROUT ["DATA,","1,","2,","3",13]

or:
HSEROUT ["DATA,",DEC x,",",DEC y,",",DEC z,13]

Those will show in different columns. If you want more rows, then more like their basic stamp example.

mackrackit
- 24th January 2011, 16:08
Did the basic stamp send in True or Inverted mode?

ScaleRobotics
- 24th January 2011, 16:41
Did the basic stamp send in True or Inverted mode?

Good point Dave,

The Basic Stamp sends it out as true, but it is done on the BS2 programming port, which has a max232 equivalent, so it can be read from the computer side. Since Don said he could read it in hyperterminal, I assume he is using a max232 device. I also assume he meant he tested hyperterminal with hserout. So maybe it is just in the wrong format.

From another page in the help file:




Strings not beginning with directives will be ignored.



So maybe this is the hang up?

It would be great to see a solution, and write up in the Wiki area (Hint, Hint).

Walter

dbachman
- 24th January 2011, 21:57
Good point Dave,

The Basic Stamp sends it out as true, but it is done on the BS2 programming port, which has a max232 equivalent, so it can be read from the computer side. Since Don said he could read it in hyperterminal, I assume he is using a max232 device. I also assume he meant he tested hyperterminal with hserout. So maybe it is just in the wrong format.

From another page in the help file:


So maybe this is the hang up?

It would be great to see a solution, and write up in the Wiki area (Hint, Hint).

Walter


FYI

I got it working ok except I haven't been able to send back to the PIC yet.

Thanks Walter....


HSEROUT ["LABEL",",","Don's",",","Test",13]
PAUSE 10
Loop:
FOR x = 1 to 5
HSEROUT ["DATA",",","Hello",",","World",",","Goodbye",13]
PAUSE 5000
NEXT x
PAUSE 10000
HSEROUT ["CLEARDATA",13]
GOTO Loop
END