CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to start communication between PIC and pc? (solved)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
irmanao



Joined: 08 Apr 2015
Posts: 77

View user's profile Send private message

How to start communication between PIC and pc? (solved)
PostPosted: Fri Sep 15, 2017 10:42 am     Reply with quote

I am working with a brand new laptop with windows 10 that doesn't have
an RS232 input. So i bought a usb to rs232 cable and a max232 module
( http://www.ebay.co.uk/itm/MAX232CSE-Transfer-Chip-RS232-To-TTL-Converter-Module-COM-Serial-Board-J8V5-X5N6/282540025003?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649 ).
I also installed this driver ( https://serialio.com/drivers-and-set-up-usb-rs-232-adapter-in-windows ).
So i connect the PIC (16f1827) to the max232 module and that to the cable and pc.
I then open the SIOW (from ccs) but i think it doesn't read the cable. On the
window comports there is only telnet and that's where i get stuck...
Can you guys tell me where along this process i am doing something wrong?
thanks


Last edited by irmanao on Sun Sep 17, 2017 3:35 am; edited 1 time in total
asmallri



Joined: 12 Aug 2004
Posts: 1630
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: How to start communication between PIC and pc?
PostPosted: Fri Sep 15, 2017 11:58 am     Reply with quote

irmanao wrote:
I am working with a brand new laptop with windows 10 that doesn't have
an RS232 input. So i bought a usb to rs232 cable and a max232 module
( http://www.ebay.co.uk/itm/MAX232CSE-Transfer-Chip-RS232-To-TTL-Converter-Module-COM-Serial-Board-J8V5-X5N6/282540025003?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649 ).
I also installed this driver ( https://serialio.com/drivers-and-set-up-usb-rs-232-adapter-in-windows ).
So i connect the PIC (16f1827) to the max232 module and that to the cable and pc.
I then open the SIOM (from ccs) but i think it doesn't read the cable. On the
window comports there is only telnet and that's where i get stuck...
Can you guys tell me where along this process i am doing something wrong?
thanks


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

View user's profile Send private message

PostPosted: Fri Sep 15, 2017 12:16 pm     Reply with quote

Oh yeah, i forgot. I tried to be thorough..
http://www.ebay.co.uk/itm/USB-to-RS232-USB-Converter-Cable-BT/281980000262?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649


thanks
temtronic



Joined: 01 Jul 2010
Posts: 9112
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Sep 15, 2017 12:40 pm     Reply with quote

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: 19224

View user's profile Send private message

PostPosted: Fri Sep 15, 2017 1:58 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Sep 15, 2017 2:54 pm     Reply with quote

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: 1630
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Sep 15, 2017 5:10 pm     Reply with quote

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: 543
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Sat Sep 16, 2017 6:25 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Sep 16, 2017 10:32 am     Reply with quote

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...
Sad
I also downloaded teraterm which seems to be quite simple.

thanks for the help guys
Ttelmah



Joined: 11 Mar 2010
Posts: 19224

View user's profile Send private message

PostPosted: Sat Sep 16, 2017 11:40 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group