View previous topic :: View next topic |
Author |
Message |
irmanao
Joined: 08 Apr 2015 Posts: 77
|
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: How to start communication between PIC and pc? |
Posted: Fri Sep 15, 2017 11:58 am |
|
|
The devil is in the detail "So i bought a usb to rs232 cable" this is where you need to provide more information. Do you have a link? _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
irmanao
Joined: 08 Apr 2015 Posts: 77
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Fri Sep 15, 2017 12:40 pm |
|
|
OK, step back a couple paces....
Disconnect the PIC and jumper pin2 of the DE9 to pin 3 of the DE9 connector. This will provide a 'loopback', so that every press of the PC keyboard will be echoed back onto the PC screen when using a 'terminal' program. I've been using RealTerm for years, so I'll 'assume' SIOW is a terminal program.
Once you're running the terminal program, you will have to select the comport that is the USB<>RS232 module.
The 'easy' (well, supposedly easy) way is to run the terminal program WITHOUT the USB<>RS232 module plugged in, see what comports are available....THEN... connect the module. Windows 'should' see it, load the driver, etc. and then the terminal program should see it too.
Once you're that far, press a few keys and confirm you can see them on the screen.
After this works THEN remove the 2-3 jumper and connect PIC.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Fri Sep 15, 2017 1:58 pm |
|
|
Step back a little further. With the cable attached, go into device manager. It should have an entry for com ports. Select this and it should list all the ports on your system. Assuming the machine has nothing else emulating a serial, there should only be one entry. Select this, and in the stuff there it'll tell you the com port number it is using. This is what you have to tell Telnet to use. If there isn't a listing for com ports, then the adapter is not being recognised by Windows. If this is the case there should be an 'unrecognised' or 'unknown' device listed somewhere under USB. You'll have to load drivers for this. Windows knows most devices now, but if it is not recognising the device you'll need to find drivers. Note down the VID & PID shown for the device and search online for drivers for this combination.
Once you have a com port number, then move to Temtronic's 'loopback' test. |
|
|
irmanao
Joined: 08 Apr 2015 Posts: 77
|
|
Posted: Fri Sep 15, 2017 2:54 pm |
|
|
Ok, there was a problem with the previous driver
but now the port is read correctly. I also did the
test that temtronic mentioned and it works. However,
when the PIC is connected i get random characters on
the terminal. I'm using the SIOW terminal, for some reason
Realterm doesn't even open on my pc.
ccs:5.008
Code: | #include <16f1827.h>
#fuses NOWDT,NOPROTECT,NOLVP
#use delay(internal=8000000)
#use rs232(baud=9600,xmit=PIN_B5,rcv=PIN_B2,bits=8,ERRORS)
void main(void)
{
while(1)
{
printf("Hey \n \r ");
delay_ms(1000);
}
} |
Something weird: if i disconnect the PIC and do
the loopback test and then connect the PIC again
i get the correct results but only for a couple of seconds,
then the randomness begins.
thanks |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Fri Sep 15, 2017 5:10 pm |
|
|
irmanao wrote: | Ok, there was a problem with the previous driver
but now the port is read correctly. I also did the
test that temtronic mentioned and it works. However,
when the PIC is connected i get random characters on
the terminal. I'm using the SIOW terminal, for some reason
Realterm doesn't even open on my pc.
ccs:5.008
Code: | #include <16f1827.h>
#fuses NOWDT,NOPROTECT,NOLVP
#use delay(internal=8000000)
#use rs232(baud=9600,xmit=PIN_B5,rcv=PIN_B2,bits=8,ERRORS)
void main(void)
{
while(1)
{
printf("Hey \n \r ");
delay_ms(1000);
}
} |
Something weird: if i disconnect the PIC and do
the loopback test and then connect the PIC again
i get the correct results but only for a couple of seconds,
then the randomness begins.
thanks |
If the randomness is occurring when the message is being sent (no random characters during the idle period) then there is likely a problem with the baud rate. Maybe the PIC is not running at 8MHz or you have not setup the comms parameters correctly on your terminal session. Another possibility is there is no common earth between the PIC's negative rail and the PC's ground connection on the serial port. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
benoitstjean
Joined: 30 Oct 2007 Posts: 566 Location: Ottawa, Ontario, Canada
|
|
Posted: Sat Sep 16, 2017 6:25 am |
|
|
My two cents worth, if you want to avoid lots of trouble, just buy a very simple and effective FTDI smart cable from DigiKey. Been using them for years and they are great. They have USB to serial 1.8V, 3.3V or 5V.
Check on DigiKey website. Next day delivery and less than 30$ Canadian.
I've been using them with PIC24's and PIC18's for years and they work great.
I also use Tera Term which works all the time and is free.
Ben |
|
|
irmanao
Joined: 08 Apr 2015 Posts: 77
|
|
Posted: Sat Sep 16, 2017 10:32 am |
|
|
I'm powering the PIC (which is running at 8MHz) and the max module from the pc and the comm parameters are right..
Ok a friend of mine gave me his usb to rs232 cable and it now works fine...
I also downloaded teraterm which seems to be quite simple.
thanks for the help guys |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sat Sep 16, 2017 11:40 am |
|
|
I suspect the lesson is that many of the cheaper cables do not do what they should.
In this case, I'd think the most likely thing is that it is not properly generating or accepting RS232 signalling levels, hence the problems. A _lot_ of the basic cables use positive only 5v signalling, and don't generate the -ve voltage needed for RS232, instead 'relying' on 0v being accepted as the mark level (actually 'undefined' in the RS232 specification). The other possibility is it used something like the WinChipHead core chip, that is famous (infamous...), for giving unreliable serial.
That the other cable works is good news. |
|
|
|