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 CCS Technical Support

reading two strings simultaneously!!!
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








PostPosted: Fri Feb 10, 2006 4:08 am     Reply with quote

Well, ive tried the following two changes, but the result is the same. i.e two digits received only. Only once it receives the total chunk of 3,mostly in the beginning.
Code:

fgets(sensorin,SONARIN_REMOUT);
disable_interrupts(GLOBAL); 
fprintf(PC,"%s",sensorin);
enable_interrupts(GLOBAL);

and
Code:

disable_interrupts(GLOBAL);
fgets(sensorin,SONARIN_REMOUT);   
fprintf(PC,"%s",sensorin);
enable_interrupts(GLOBAL);


I dont have a hardware debugger, otherwise it wdve bn easier to figure out the problem
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 10, 2006 9:11 am     Reply with quote

Post the Manufacturer and part number of the sensor.

Also post a link to the website with the data sheet for the sensor.
Guest








PostPosted: Fri Feb 10, 2006 12:13 pm     Reply with quote

Before i mention the manufacturer, let me describe the system further. An ultrasonic rangefinder is controlled by a PIC MCU which ranges and sends this range over RS-232 to the main MCU on which i have this program running. The data (3digits followed by <CR>) is being sent once per second.

Now, in my opinion, the problematic part is serial communication between the MCUs. I have checked the output from my first MCU on the terminal separately and its fine.
Anyways the sensor is the polaroid senscomp 6500 whose datasheet is found at:
http://www.acroname.com/robotics/parts/R11-6500.html

Hope we'll find a problem to this solution soon ...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 10, 2006 2:10 pm     Reply with quote

I think I see what the problem is. I should have seen it a lot sooner,
but you posted so much code. That's why I always ask for a short
test program.

First you wait for a short message to come in from the hardware UART.
Then you re-transmit it to the PC with a software UART. While you are
doing this, it's likely that a new message is coming into the hardware
UART. You are locked out of servicing the hardware UART for 4
character periods. But the hardware UART can only buffer up 3 chars.
So you will lose one. You have the ERRORS directive in your #use
rs232() statement, so the overrun error will be cleared and the UART
won't lock up. So instead of getting a message such as ABC<CR>
you will get AB<CR>. The third character will be lost.

Quote:
while(1)
{
fgets(sensorin,SONARIN_REMOUT); // Get 4 chars with H/W UART
fprintf(PC,"%s",sensorin); // Send 4 chars to PC with soft UART
Guest








PostPosted: Sat Feb 11, 2006 2:11 am     Reply with quote

Thank for all your replies. I was sending it on the PC for debugging only and as i comment it out the problem gets solved! So it turns out to be a UART buffer overrun problem.
Another solution could probably be, to start shoving the characters into a FIFO. Plz paste a link on soft vs hard serial transfer, and problems like these reported previously and Thanks again !
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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