Communication options

Thread Starter

geoffers

Joined Oct 25, 2010
488
Hi all,
I would like some advice on comunicating between a PIC and pc. I've not attempted this yet so my questions maybe basic. The outline of my project is a reader I've made to read ISO 11784/11785 tags. My latest version uses a PIC18f2523 with a 24lc512 serial eeprom added. This gives me capability to store up to 10,000 tags. I would like to be able to transfer the tag numbers to a pc, idealy to a spreadsheet. I'd like to know what my best options are? I see microchip do a chip to set up a usb port? However I've heard of people using the on-board UART and hyperterminal? Software advice at the pc end would be good to? Is there a simple way of getting my data into a spreadsheet? The tag number is stored in 6 bytes, one of which has to be separeted to interprate to give one two byte number and another 5 byte number. Would I have to send out 6 bytes or change the number into assci characters and send it as a 'decimal' number? Its easier for me to make changes to the pic as I kind of understand them! I programme in mpasm.
Sorry for the rambling post, any advice would be welcome.
Thanks Geoff
 

MrChips

Joined Oct 2, 2009
30,824
There are many options. The simplest that comes to mind is:
if your PIC does not have USB, then use the UART output and convert to RS-232 interface.
Connect directly to a COM port on your PC. If none is available, get a RS-232 to USB converter cable.

To test the connection, use Hyperterminal.
Convert all output into decimal strings.
You can use Hyperterminal to Capture Text and save to a text file which you can read into your spreadsheet.

Later you can use a utility which will allow the spreadsheet to read the COM port directly.
 

Thread Starter

geoffers

Joined Oct 25, 2010
488
Thanks for that, been doing a bit of digging, microchips an774 would seem to go in the right direction, I already have the usb to serial adaptor for my picstart plus programmer. The max232cpe looks like a suitable chip to use for conversion to rs232 signals? Any thoughts or advice on using that setup would be welcome.
Thanks Geoff
 

kubeek

Joined Sep 20, 2005
5,795
Thanks for that, been doing a bit of digging, microchips an774 would seem to go in the right direction, I already have the usb to serial adaptor for my picstart plus programmer. The max232cpe looks like a suitable chip to use for conversion to rs232 signals? Any thoughts or advice on using that setup would be welcome.
Thanks Geoff
Maybe you could avoid the double conversion to RS232 and back if you tap inside the the adaptor. The adaptor will likely have one chip that converts USB to UART and then another that converts UART to RS232, so it could be easier to tap in the uart than setting up a max232.
 

Thread Starter

geoffers

Joined Oct 25, 2010
488
Hi,
Thats a interesting idea, just popped the serial addaptor open and there are indeed two chips in there, tapping into them looks quite tricky though, lots of pins very close together, I've got a max3232cpe now so I think I'm going to tackle it that way.
Cheers Geoff
 

Thread Starter

geoffers

Joined Oct 25, 2010
488
Hi all,
Now have the max3232cpe wired up to a 18f2523, I've configerd the usart according to microchips an 774 and wrote a programe to output a incrementing 8 bit number. The baud rate is set at 9600 in the code. At the moment I'm running the int osc at 4mhz. With my scope I can see the signal coming out of the max, its 15v peak to peak. Unfortunatly I'm getting nothing out of hyperterminal. When I connect up the serial lead to the max my nice clean looking signal turns into a messy looking thing. I've got the output of the max connected to pin2 on a nine pin rs232 to usb addapter, should the signal stay clean looking or is it normal to go all rough looking and I have a problem elsewhere?

Thanks Geoff
 

kubeek

Joined Sep 20, 2005
5,795
If you can, toggle another pin active when you send the char to trigger a stable trace on the scope, keep sending the same byte and see what it changes to when you connect the max3232.

Also, do you have the signal levels and supply voltages right? Can you post a schematic?
 

MrChips

Joined Oct 2, 2009
30,824
When you are testing serial output for the first time, send binary 01010101 followed by a long pause such as 20ms and observe on the scope.
Measure the single bit width to confirm correct baud, number of bits, start and stop bits, and voltage polarity.
 

Thread Starter

geoffers

Joined Oct 25, 2010
488
Hi everyone,
Thanks for the swift replies, been tinkering about with it, I got the 18f2523 to output 01010101, then changed it to 10101010, the bit length is 1.05-4 which by my sums is pretty close to 1/9600. It would appear I have one start bit high and a stop bit low? Is this right for rs232, I thought it should be start bit low stop bit high but I may have dreamt it?
I might not have made it clear in my last post, The signal comes out of the max just fine, its when I connect up the rs232 to usb lead its goes fuzzy? The output from the max is roughly +/-8v or 16v peak to peak which I think is about right?
Thanks Geoff
 

kubeek

Joined Sep 20, 2005
5,795
Can you elaborate on the fuzziness? And please draw some schematic of how you have all the chips connected and powered, you could be having problems with ground loops.
 

Thread Starter

geoffers

Joined Oct 25, 2010
488
Hopefully there should be a pdf attached with a basic schematic, I've left off the four capacitors for the max's charge pump, I've check their values and they seem to be right. By fuzziness I mean the nice square signal without the lead connected goes all spikey on the top of the positive side, the negative remains clean? If I dissconnect gnd(pin5 of the 9pin connector it cleans up again?)
Thanks Geoff
 

Attachments

kubeek

Joined Sep 20, 2005
5,795
Have you tried it with just the gnd connected and not the data pin?
Also check how does the 5V rail look like with and without the connections.
 

Thread Starter

geoffers

Joined Oct 25, 2010
488
Hi,
I get the same result by disconecting the rxd pin, fuzzy bit goes. Seems to only be there when its connected up. Just to check, I should have the output of the max connected to pin2 (rxd) of the rs232? The 5v rail is quite busy, theres a lcd and two transponder reader ics (they are both asleep when I test the usart though. Is there a easy way to check hyperterminal is working ok? The usb to 232 addaptor is working fine when I use it for my picstart plus, so I also know I'm checking the right com port.
Thanks Geoff
 

kubeek

Joined Sep 20, 2005
5,795
Yes you should have connected tx from max connected to rx on rs232.
So is the 5v supply reasonably clean, and doesn´t change when you connect the rx?
 

Thread Starter

geoffers

Joined Oct 25, 2010
488
Just put the scope on it and the 5v line stays nice and steady. However I have just found another usb/serial adaptor and that one doesn't affect my signal! But when I try to connect to com4 its not shown, begs the question as to which adaptors not working right?
Thanks Geoff
 

Thread Starter

geoffers

Joined Oct 25, 2010
488
Hi all,
Not sure what my problem with the MAX3232cpe was. I've now got hold of a USB>TTL cable from rs in the uk. It works a treat, you can connect it right up to the pic's uart and the pc see's it as a comm port. For anyone like me (a bit simple?) its a easy way to do pc<>pic comms.
Thanks for all your advice,
Geoff
 
Top