Serial to USB "FTDI"

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Serial to USB "FTDI"

Post by Desdewit »

Hi There

I've connected my serial to usb board to my pc via an FTDI chip, installed the FTDI driver and tested the communication with a test program written in basic so I know the hardware is working.
When I use my test program from FC5 the data received by the pc is corrupt.
I've tested both with:
9600baud
One stop bit
No Parity
8 Data bits
No flow control
Oscillator: HS-PLL 32.0000 MHz, 8.0000 MHz Crystal
Attachments
Ready for Pic Test Board.fcf
(8 KiB) Downloaded 267 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Serial to USB "FTDI"

Post by Enamul »

Hi,

Not quite clear what you are trying to d here? Can you please tell us what is your goal here?
Enamul
University of Nottingham
enamul4mm@gmail.com

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Serial to USB "FTDI"

Post by kersing »

Have you tried the simple 1 second blink test to check if your clock settings in Flowcode are correct?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Serial to USB "FTDI"

Post by Desdewit »

Hi Enamul & Kersing

I'm trying to send data from my pic serial port to pc via usb.
I know the hardware is working, I've tested it with a program written in basic so the problem must be my setup in flowcode or flowcode self.
I've also done the 1 second test and the timing is ok.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Serial to USB "FTDI"

Post by Enamul »

Hi
I can't see anything wrong in the Flowcode config. It should work easily. Have you tried to send data to PC (terminal or Hyper-terminal) over rs232 from PIC?
Enamul
University of Nottingham
enamul4mm@gmail.com

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Serial to USB "FTDI"

Post by medelec35 »

Hi Desdewit,
To enable PLL if required when using internal or external osc.
I thought these devices require a C code block at the beginning with

Code: Select all

st_bit(osctune,PLLEN);
and enable PLL in the configuration menu

What Value crystal or resonator are you using?

I could be wrong of course.
If I'm right, I am surprised the one second test was accurate.
Do you have access to a scope so the baud rate can be measured?
Martin

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Serial to USB "FTDI"

Post by Desdewit »

Hi medelec

Unfortunately I don’t have a scope but I’ve done the one second test again and it seems pretty close to my pc clock with the c block and pll enabled but still no success.
I’m running a 8MHz Crystal

Almost forgot “I’m also using the second Rx & TX channel of the pic for rs232 to pc and the data received are ok" so the timing must be correct.

Mathy
Posts: 333
Joined: Mon Oct 05, 2009 2:39 pm
Has thanked: 30 times
Been thanked: 33 times
Contact:

Re: Serial to USB "FTDI"

Post by Mathy »

Is it possible to have your schematic ?

I'm working with pic and FTDI chip every day and it works like a charm.

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Serial to USB "FTDI"

Post by Desdewit »

Hi Mathy

I'm using the ready for pic board from mikro electronika.
The hardware are working with the hex file from pic basic but not with the hex file from flowcode so this looks like it might be a flowcode error.

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Serial to USB "FTDI"

Post by kersing »

Can you connect the FTDI module to the second channel? That works with a serial connection, so speed, bits, etc are set right and it should work with the module as well... If it does we have confirmation there is something suspect with the code for channel one.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Desdewit
Posts: 130
Joined: Sat Feb 26, 2011 4:26 am
Location: South Africa
Has thanked: 25 times
Been thanked: 11 times
Contact:

Re: Serial to USB "FTDI"

Post by Desdewit »

Hi kersing

Thanks for the reply, Changed the baud to 38400 now it's working.

This is a link to the web page of the board I'm using
The board comes with sample filles to test the hardware.

http://www.mikroe.com/ready/pic/

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Serial to USB "FTDI"

Post by kersing »

You had to change the speed of the FTDI adapter to 38400?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Gary Freegard
Posts: 45
Joined: Mon Nov 07, 2011 6:36 pm
Has thanked: 1 time
Been thanked: 30 times
Contact:

Re: Serial to USB "FTDI"

Post by Gary Freegard »

Hi Kersing

The baudrate that is selected when the FTDI or equivalent is connect to the PC must be the same value as was programmed into the PIC.
Unless you write some code to automatically change the baudrate of the PIC to match the FTDI, in the RS232 component the is a macro for
changing the baudrate.

Gary

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Serial to USB "FTDI"

Post by kersing »

Gary Freegard wrote: The baudrate that is selected when the FTDI or equivalent is connect to the PC must be the same value as was programmed into the PIC.
Hi Gary,

The first message states 9600 bps is used. Later 38400 is mentioned. I was trying to find the answer to the question where adaptions had been made (PIC, FTDI, both?). Having used RS232 components for many years I am very aware of the need to set both sides to the same speed :-)

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Post Reply