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

serial string operations

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



Joined: 02 Sep 2010
Posts: 2

View user's profile Send private message

serial string operations
PostPosted: Mon Sep 06, 2010 8:11 am     Reply with quote

Hi!
I have one case, when I get some text message from a pc serial port, and i have to make some mathematical computation with this text and send it back to the pc. Can I do this kind of job with a pic?
So for a example:
I got from a pc a text containing 123 and I have to add 2 to each number(or letter) and I have to send back 345 to the pc. Could I do this with a pic? And whats happening if I get some mixed text (AB12C ?? How can I add 2 to each character?).
This is just a beginning of the problem, later I have to make some other operations with this text (XOR, etc), but for the beginning I want to understood is this job possible to solve with PIC MCU...
Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19536

View user's profile Send private message

PostPosted: Mon Sep 06, 2010 8:53 am     Reply with quote

They are all quite easy to do with a PIC.
Put it into perspective, there are people here, who have written complete factory control systems 'in a PIC'.
What you need to do, is work out how much data needs to be 'held' at any time (this will determine how much RAM the PIC you look at will need to have).
Are you sure you want to be using a 'serial port'. Remember that most PC's these days don't have such a port - you might want to consider a PIC that can implement a USB emulation of such a port instead?.

Best Wishes
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Mon Sep 06, 2010 4:35 pm     Reply with quote

I have a PIC I'm working on now that going to be used in a sensor project... currently it:


* uses the PWM module to clock a Linear Tech delta-sigma ADC so the PIC can measure 16 analog inputs via SPI interface while interleaving occasional temperature measurements from the same ADC.

* takes packets from the host PC using the RS232 RDA interrupt.
* transmits packets back to the host using RS232 TBE interrupt.
* uses the timer0 Interrupt to tick seconds that starts a main loop state machine
* does some floating point calcs in between all this.
* controls a valve every minute (60 seconds)


It's pretty busy and only consumes about 20Kb of ROM and 1K of RAM.

It runs on a 10MHz TCXO (using the PLL to clock system at 40MHz)..

It's pretty busy -- but then again, it's kinda not.

You can do a LOT of stuff with a PIC. I love 'em.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D


Last edited by bkamen on Tue Sep 07, 2010 12:28 pm; edited 1 time in total
xeon



Joined: 02 Sep 2010
Posts: 2

View user's profile Send private message

PostPosted: Tue Sep 07, 2010 11:59 am     Reply with quote

Thanks for the answers!
I have to use serial port. And about 20-30 characters need to be received in one packet with 9600 baud. The number of the caracters is not allways same.
I bought a pic 16f628. Can i make this job of mathematical conversion with this pic?
Can sb. give me some simple example how can i store the received textual characters and make the conversion?
Thanks
bkamen



Joined: 07 Jan 2004
Posts: 1615
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Sep 07, 2010 12:27 pm     Reply with quote

xeon wrote:
Thanks for the answers!
I have to use serial port. And about 20-30 characters need to be received in one packet with 9600 baud. The number of the caracters is not allways same.
I bought a pic 16f628. Can i make this job of mathematical conversion with this pic?
Can sb. give me some simple example how can i store the received textual characters and make the conversion?
Thanks


Depends on the format.

I get the feeling you don't know how to write in C from your questions... so the freebie for today is:

* You store information in a string. Then you convert it by hand (code you wrote) or a predefined library call like maybe atoi() or some such.
* Then you go out an buy a book on C. A good choice here is "The C Programming Language" by Kernighan and Ritchie. ISBN 0-13-110362-8. Read it.
* Then pour over all the examples of string handling in the PIC-C Examples directory.


Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
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