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

Sensor's and PIC

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



Joined: 22 Jan 2011
Posts: 25

View user's profile Send private message

Sensor's and PIC
PostPosted: Tue Jan 25, 2011 5:08 am     Reply with quote

How can I implement code with PIC for example 12f683 if I need to read "data" from 3-5 sensors(for beginning voltage and current, then GPS...), which are connected in parallel, on only "1 wire"; any ideas any example, is this rs232?

I would like to read then from each sensor in this way:
Time line - Event
0ms - 1ms Sync Pulse
10ms - Sensor 1
20ms - Sensor 2
.....
.....

Many thanks
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Jan 25, 2011 7:09 am     Reply with quote

Your reference to 1-wire probably means the Dallas series of chips(temp sensors,RTC,etc) used close to a microcomputer but to me it means the propriatory single wire system I designed almost 30 years ago for remote energy control that easily communicated over 25 miles of copper,still in use today.

There are examples in the example folder that CCS supplies with PCM...and tons of 'projects' on the Web that use the Dallas products.
I suggest you buy a couple that will do what you want,read the data sheets,look for examples , cut code,burn PICs and have fun.
You'll learn more by doing and the Web is a great tool.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Jan 25, 2011 9:28 am     Reply with quote

Read up on the Dallas 1-wire protocol and see if that will do what you need. If not, you will likely have to create your own.
_________________
The search for better is endless. Instead simply find very good and get the job done.
thaking



Joined: 22 Jan 2011
Posts: 25

View user's profile Send private message

PostPosted: Tue Jan 25, 2011 9:42 am     Reply with quote

Well I was thinking in this way:

I have for example pic12f683, with one PIN left OPEN (A3)

For beginning I would like to measure from this pin voltage and current, measures were be done in some "order", 1. voltage, then current...with delay...

Can be this done, with just one PIN on PIC?

thanks
thaking



Joined: 22 Jan 2011
Posts: 25

View user's profile Send private message

PostPosted: Tue Jan 25, 2011 12:03 pm     Reply with quote

Any ideas? Rolling Eyes
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Tue Jan 25, 2011 12:37 pm     Reply with quote

How are you going to measure current with 1 pin? You need to think more about just what you are asking for.

You can use 1 pin of your pic12f683 to talk to other processors, or to smart peripherals that have their own processing power. But the only thing you can directly measure with a single pin is a voltage.
_________________
The search for better is endless. Instead simply find very good and get the job done.
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Tue Jan 25, 2011 3:41 pm     Reply with quote

Assuming your sensors can talk RS232, look at EX_PBUSM.C in the CCS example directory. It shows a simple protocol for "one-wire" (wired-or) rs232 comms between multiple devices.
thaking



Joined: 22 Jan 2011
Posts: 25

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 4:43 am     Reply with quote

This rs232 means port rs232 on PC? Or just means protocol, which also use old PC's and micro controllers?
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 6:48 am     Reply with quote

It is unfortunate that CCS decided to call their asynchronous serial function RS232 because the actual RS232 spec deals with voltage levels that no PIC can directly support.

On this forum and with this compiler RS232 means async serial at TTL voltage levels unless a level shifter chip is specified.
_________________
The search for better is endless. Instead simply find very good and get the job done.
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 7:01 am     Reply with quote

RS232 generally means a serial form of communications,usually using some form of 'UART' and a 'MAX232' or similar interface chips to invert and buffer the nominal 0 or 5 volt 'TTL' signals from the device.Typically the 'data stream' consist of a start bit..several data bits(5...8) and a stop bit at speeds from 50 Baud up to 1megabaud.There are usually two devices connected with a minimum of 3 wires(gnd,xmt,rcv).
Naturally, over the years,it's be 'used and abused',modified to accomodate conditions and design requirements.
I modifed it about 30 years ago to allow a host to communicate to 512 slaves up to 25 miles away on solid copper wire(phone lines).By using am interlaced, bidirectional scheme I am able to both transmit and receive data on one wire,similar to the 'Dallas 1-wire',just a whole lot further !
Some people to not use the buffer chips,some run at non standard baud rates, so it is important to know the specs of the system you're connecting to.There is no official 'standard', just 'guidelines' nowadays.
thaking



Joined: 22 Jan 2011
Posts: 25

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 8:03 am     Reply with quote

So uart=rs232; if this is same so there is TX and RX +voltage?
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 9:26 am     Reply with quote

This is one of those 'common usage', versus 'real answer' bits....

RS232, is a signaling voltage standard. It uses negative voltage for a '1', and positive for the '0', with a requirement for at least +/-5v, into a 3KR load.

No PIC, can actually generate 'RS232'.

However the commonest signals sent 'over' RS232, are async serial. This has a line that sits 'idle', and then a pulse train, starting with a '1' pulse (start bit), followed by typically 7 or 8 'data' bits, and followed by an optional 'parity' bit, then a '0' (stop) bit.
The key thing here is that the data is 'self timing'. Provided you have a clock at the receive end, that is reasonably 'close' to the transmitter, you can look for the transition from the 0/idle state, to '1' (the start bit), and then time the bits at 1.5, 2.5, 3.5 etc., 'bit times' from this point. Provided your clock does not drift by more than say 1/3rd a 'bit' time from the clock at the other end, in the length of the 'character' being sent, you still receive the correct data. Since no separate 'clock' is sent, it is an 'asynchronous' transmission - no synchronising clock.

The PIC UART, generates async serial, using the chip's signaling voltages (inverted). Often called 'TTL async serial', since the earliest UARTs, used TTL voltage levels, on their outputs, and the PIC outputs/inputs, are compatible with these.

The reason for the inversion, is 'historical', with the commonest driver chips to generate the RS232 voltages, being 'inverting' drivers. The commonest for many years, has been the 'MAX232'.

So to generate 'RS232', you need the PIC UART (or a software emulation of this), connecting to a MAX232 (or similar driver chip).

However the same PIC connection, can also connect to (say) a MAX485, and then the signals can be sent over the RS485 standard instead.
Equally, the signals can be connected (for short distances), without using any buffering at all.
Unfortunately, since the commonest connection was 'RS232', CCS elected to call the commands to setup this, 'USE RS232', though it doesn't actually 'use' RS232....

So, PIC UART, does not give 'RS232', but with one buffer chip, does.

Best Wishes
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 11:09 am     Reply with quote

Too bad they didn't call it SIO or TTLSIO instead of RS232,would have been more appropriate but ya can't turn back the clock !
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