Connecting RS-232

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
andy20989
Posts: 6
Joined: Mon Nov 19, 2007 5:02 pm
Contact:

Connecting RS-232

Post by andy20989 »

Hey Guys,

I have another problem- basically im trying to control a motor controller using a simplifier serial rs-232- which is uses TTL level single byte serial commands to set the motor speed and direction. It is one direction only.

First of all which pin is the default connection on an 18F4455 dil chip?

can you give me some example code to send '127' to the motor please?

Also on the expert configuration screen what should i select / disable? I am using a 4mhz crystal.

Many Thanks,


Andy

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Connecting RS-232

Post by Benj »

Hello Andy

The Transmit pin of the 18F4455 is RC6 or pin 25 it is marked with a TX.

An example of sending 127 would be to include the RS232 component into your program and then using a hardware macro send RS232 byte and in the parameter input place 127 or the variable holding 127. You will have to go into the RS232 component properties to set the baud rate and flow control. Also make sure the clock speed in Flowcode is correct for your crystal.

Expert Config Screen example.
Clk source OSC1/OSC2 - Clock from Crystal
div by 4 - Normal 1:4 operation
no divide - No effect in crystal mode
XT-USB:XT - for a 4MHz crystal or below / HS-USB:HS for a higher value
PortB configured as digital I/O - Starts PortB as digital I/O
MCLR Enabled - Enables the reset pin
Everything else disabled (especially watchdog timer)

Hope this helps.

andy20989
Posts: 6
Joined: Mon Nov 19, 2007 5:02 pm
Contact:

Re: Connecting RS-232

Post by andy20989 »

I'll have a bash and let you know tomorrow :-)

alain31
Posts: 10
Joined: Sun Feb 24, 2008 6:32 pm
Location: Toulouse FRANCE
Contact:

Re: Connecting RS-232

Post by alain31 »

Hi MatrixMultimedia team,

I've got another RS232 problem ...
I recently purchased FlowCode, because of my poor software programming skills, Flowcode sound a lot easier.
However, to debug my programs, which run on a PIC16F877A CPU board that I built, I use the RS232 trhough a MAX232 connected to my PC and displayed via TeraTermpro. After a few tests and having read all RS232 posts on this forum, I am unable to display a single character on y screen.
My hardware is working, I tested it back with a little C software and simple "printf" command. But with flowcode, the only character displayed is a + upon a minus sign. RX is connected to RTS pin7 and TX to CTS pin6 of Port C on the RS232 Flowcode component, both sides at 9600 Bds.

I saw also on this^post that you refer to "Expert Config Screen", where can I find this screen, didn't see it ? Could it help ?

Alain

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Connecting RS-232

Post by Benj »

Hello

The expert config screen is available from the Chip -> Configure menu of flowcode.

Make sure that your clock speed is correct in Flowcode and that you are using the XTAL or HS mode of operation.

alain31
Posts: 10
Joined: Sun Feb 24, 2008 6:32 pm
Location: Toulouse FRANCE
Contact:

Re: Connecting RS-232

Post by alain31 »

Thanks Benj for the answer,I understand that the expert configuration screen is from PPP software.
Unfortunatly, the 16F877 on which I try to load my programm is on a developpment board I built. And you know what, I have only the serial port to upload my program. And it seems to me that PPP has been designed to load software through parallel port or USB. Am I right ?
Is there any way to use serial port anyway ? Or Can I use a USB-RS232 adaptater ?

At the moment, I am able to load my software using a bootloader and RS232, but it seems I miss all the configuration bits.
Thanks for your answer

Alain

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Connecting RS-232

Post by Benj »

Hello Alain

You can still use your programming software. PPP actually embedds the config information into the hex file so as long as the chip is configured correctly in Flowcode the hex file should be alright to send using your programming software.

The adapters you mentioned sound like they would be more trouble then they are worth.

alain31
Posts: 10
Joined: Sun Feb 24, 2008 6:32 pm
Location: Toulouse FRANCE
Contact:

Re: Connecting RS-232

Post by alain31 »

Right Benj,
So I have to put the configuration into an additionnal C code control box ?
Actually I tried last night, but every time, what I've got was a compiling failure from C to asm :
D:\Matrix Multimedia\Flowcode V3\Exemples 16F877\TUT_09_printf.c(303): error: missing semicolon
D:\Matrix Multimedia\Flowcode V3\Exemples 16F877\TUT_09_printf.c(303): error: failure


An the code itself in the box :
/*Entrer le code C après ces commentaires
Par ailleurs, pour entrer du code assembleur,
utiliser l'opΓ©rateur asm devant chaque instruction, par exemple
asm movlw 5
ou imbriquer plusieurs instructions dans un bloc asm comme ci-dessous :
asm
{
movl
Rem Configuration for PIC16F874A */
#pragma DATA _CONFIG, _CP_OFF & _PWRTE_OFF


Any idea of what i did wrong ?
Thanks.
Alain

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Connecting RS-232

Post by Benj »

Hello Alain

You do not have to code the configuration yourself. If you use the PPP tool from Chip -> Configure inside Flowcode then this information will be passed into the hex file upon compilation.

alain31
Posts: 10
Joined: Sun Feb 24, 2008 6:32 pm
Location: Toulouse FRANCE
Contact:

Re: Connecting RS-232

Post by alain31 »

Thanks Benj,
Finally, after a couple of bad results, everything's clear, uploading ok, with the right configuration, and RS232 working well.
At last, the mess I did was due to the fact that my PPP setting did not stand while doing all the tests. I should have check that, but you know ...
Well, now, the right things will begin. I keep you inform, just for the fun.
Alain

Post Reply