SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
User avatar
By anfedres
#167770
OK guys, I´ve seen that there is a lot of people out there struggling with this. I´m PIC user, I like it because it´s very cheap where I live. I like it Arduino too. Nonetheless, I wanna run this attached to a PIC.

First of all let´s start understanding the Protocol and how to send it. When I first read I noticed that part that it´s says Multibyte item is represented as Little Endian, according with some research that I did this mean that I have to send the LSB (Least significant Byte) first. Please, correct me if I´m wrong.

Command Packet (Command)

Command Start
0X55----> TYPE: BYTE 1----> Command Start Code1
0XAA----> TYPE: BYTE 2----> Command Start Code1

DEVICE ID (WORD)
0X01----> TYPE: BYTE 3----> Device ID: default is 0x0001, always fixed
0X00----> TYPE: BYTE 4----> Device ID: default is 0x0001, always fixed

PARAMETER (DWORD). In this case is the Parameter Open
0X00----> TYPE: BYTE 5----> PARAMETER
0X00----> TYPE: BYTE 6----> PARAMETER
0X00----> TYPE: BYTE 7----> PARAMETER
0X01----> TYPE: BYTE 8----> PARAMETER

COMMAND (WORD). OPEN
0X01----> TYPE: BYTE 9----> COMMAND OPEN
0X00----> TYPE: BYTE 10----> COMMAND OPEN

CHECKSUM (WORD). BYTE ADDITION, OFFSET 0 +….+ OFFSET 9
0X01----> TYPE: BYTE 11----> COMMAND OPEN
0X01----> TYPE: BYTE 12----> COMMAND OPEN

Guys, please. If I have a mistake, do not hesitate to point it out.

So far, it seems kind of easy. I haven´t try to program it yet. I´ll try this week. However, I do not yet which functions should I use to use with a PIC.

OK, I will be posting my progress. :dance:
By waltr
#167794
If I remember correctly the scanner outputs TTL level asynchronous ASCII. In that cas install an TTL to RS232 level translator (MAX232 or equiv.) and connect to your PC's comm port. Then use a terminal program to 'see' exactly what the scan outputs.
If the scan does not output ASCII but rather binary then either capture the data in the termail program to a file (full 8bit) then look at the file with a Hex Viewer or use a terminal program that displays the Hex values (X-CTU is good for this).
Then you'll know exactly what to expect and writing the PIC code should be easy.
User avatar
By anfedres
#167797
Waltr, thank your for helping me. Well, I´ll try your method. However, let´s say that I´m just starting. For example, I´m trying something like this.
Code: Select all
#include <18F4455.h>
#fuses XT, NOWDT
#use delay (clock=20000000)

#USE RS232 (BAUD = 9600, XMIT = PIN_B0, RCV = PIN_B1)


void main()
{

delay_ms(5000);

printf(0x55);
printf(0xaa);
printf(0x01);
printf(0x01);
printf(0x00);
printf(0x00);
printf(0x00);
printf(0x00);
printf(0x12);
printf(0x00);
printf(0x13);
printf(0x01);


}
The code above it´s the "ledON" command. But I think that I have to establish communication with the OPEN command first.

I do not know if it´s OK. Like I said, I´m just starting, if you have a hint or if you have tried to run this module with a PIC, it would be nice to have a clue in how to start. Once again, thank you. :clap:
By waltr
#167815
I think it will be harder to do from the PIC if your are unsure of the protocol.
It can be done so you will just need to keep experimenting until you get it working.

I would use a terminal program on a PC and create a file of the command values to send. RealTerm is good for this as well as TeraTerm. Then you will also see any response back from the scanner.

You did read all the comments on the scanner's product page, right?
There is Ardiuno code there that would copy to a PIC easy enough.
User avatar
By anfedres
#167818
I have read the Arduino Code. It´s true that I have to experiment much more. And I have read all the product datasheet too. I opened this post not only because I have this doubt. It´s because I know that there is people out there struggling with this too.

One specific doubt that I ihave is... Should I send the entire command in once package to the FPS, or can I send it in different packets using the putc, or putf. I havn't got good results, however, I´m at work right now. I´ll try tonight in different ways.

Thank you for your help and your response.
By waltr
#167820
These are not "packets" but just UART serial output bytes.
Most likely it will not matter if you use the putc or outf functions since these probably run faster than the serial data can be output by the UART therefore each character will be Stop bit to Start bit. If you really need to know if this is so then write code for both functions and then look at the serial output from the UART on an O'scope.

The Ardiuno code looks to just send the commands one after another.