No Flow Chart

Electronics Computer Programming Q&A
Post Reply
frank_fg
Posts: 23
Joined: Tue Apr 29, 2008 9:07 am
Contact:

No Flow Chart

Post by frank_fg » Sat Aug 23, 2008 1:12 pm

:smile: Hi! Al

I been out on an unexpected vaction, but I'm back now, ready to get with it.

My first objective is to capture the three '000' zero characters fron RS-232
receiver rcreg. from the slave PIC16F88.

As explained above, the Master will send the speed control value to the Slave. The way it is now, the Slave will not respond to '000' from the Master.

Slave Programme:

Testip: bsf portb,rb0 ; Red LED on.
call rxw ;Test for new serial data.
btfss status,z ;If z set then new data.
return ;Return if z is clear.
call txw ; Send same data byte back.
movwf reflevel2
bsf portb,rb1 ;Green LED on
return

===============================================

Rew: bcf status,z ;z flag cleared no data.
btfss pir1,rcif ;Test for new data.
return ; No data exit, z flag clear.
btfss rcreg,ferr
goto rw1
movf rcreg,w ;Move data into W.
bcf stau,z ;Framing error, z flag clear.
goto rw2

Rw1: movf rcreg,w ;Move data into W.
bsf staus,z ;Set z flag to show vaild data.
return
Rw2: btfss rcsta,oerr
return
bcf rcsta,cren ;Clear then set CREN to clear.
bsf rcsta,cern ;overrun flag OERR.
return ;Received data exit 2, W = data.
============================================

In Rw1, where it says to copy data into W:

I would think at this point I should be able get the '0' characters and
test for three of them then give the cmd. to stop.


Those that make sense to you.

Thanks

Frank G.

User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Post by MrAl » Sun Aug 24, 2008 3:15 am

Hi Frank,


If all you want to do right now is to read the '000' being sent to the
slave then the only thing you should have to do is set up the
USART receiver on the slave and work with that right?

It's hard to understand what you are doing though, perhaps a complete
drawing of your setup would help.
LEDs vs Bulbs, LEDs are winning.

frank_fg
Posts: 23
Joined: Tue Apr 29, 2008 9:07 am
Contact:

Post by frank_fg » Mon Aug 25, 2008 9:44 am

:smile: Hi! Al


The slave program was not set up to stop the motors.

But it was set up to control the speed via A/D converter using
the master keypad.

such as 010 to slow it down to its lowest speed or 248 to go faster.

The idea is to rewrite the slave program so it would take the three
'ooo' characters to stop the motors from running.

We know that we can send the three '000' characters because they are sent back to the master LCD.

What I'm trying to do is capture the three 000 from the rcreg in the
USART clear portb,rb3 and portb,rb4 which turn on the motors.

Thanks

Frank G.

frank_fg
Posts: 23
Joined: Tue Apr 29, 2008 9:07 am
Contact:

Post by frank_fg » Mon Aug 25, 2008 9:51 am

I hope you get this drawung.

User avatar
MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

Post by MrAl » Mon Aug 25, 2008 9:54 am

Hi Frank,

It's been a while now since i worked with the USART, but dont you
just wait for an interrupt and read the register value to get the
first digit, then repeat to get the next, etc.?
One simple way to test is program some code so that an LED
blinks if the right code is received, and this can be for each digit too.
One blink for the first digit, then pause 1 sec, then blink for the
next digit, then pause, etc.

My last project that involved an RS232 receiver i bit banged it for
receive just to see if i could get the timing right. Using the USART
should be much easier than that though. I'll take another look if
you are still having trouble and see what i can spot.

A LITTLE LATER...

I found this info in one of the data manuals. See if this helps at all...

When setting up an asynchronous reception, follow
these steps:
1. Initialize the SPBRG register for the appropriate
baud rate. If a high-speed baud rate is desired,
set bit BRGH (Section 11.1 “AUSART Baud
Rate Generator (BRG)â€
LEDs vs Bulbs, LEDs are winning.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests