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

Long Distance communication with RS485
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
heavenlyrider



Joined: 04 Mar 2016
Posts: 7
Location: India

View user's profile Send private message

Long Distance communication with RS485
PostPosted: Fri Mar 04, 2016 7:02 am     Reply with quote

Hi,

I have 4 mlx90614 temperature sensor which works on i2c protocol. I need to get temperature data from each of the sensors over a long distance of about 20 meters. For which i have decided to use RS485 protocol like 1 master and 4 slaves. My question is should i use 4 separate micro controllers with mlx90614 or i2c to RS485 converters like NXP's SC16IS752. Please provide me your valuable suggestions.

Thanks & Regards.
temtronic



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

View user's profile Send private message

PostPosted: Fri Mar 04, 2016 7:36 am     Reply with quote

I'd use a PIC (one with HW I2C and HW UART), sensor and RS485 xcvr on a small PCB. Actually 5 PCBs, one for each slave and the master. OK, SIX, you need a spare !!

Each 'slave' just needs to read and store the data. The 'master' would 'poll' the slaves, get the data and then 'do something' (display on LCD ?) with that data. Since you're reading temperature a scan rate of 1 Hz is probably more that suffice. I'd also use a DIP SW for 'slave address'.

Choice of PIC is up to you but go with one with lots of memory, HW I2C and HW UART. While 'bigger' than needed it allows you to use a common part for more projects !

Jay
heavenlyrider



Joined: 04 Mar 2016
Posts: 7
Location: India

View user's profile Send private message

PostPosted: Sat Mar 05, 2016 4:24 am     Reply with quote

Hi,

Thanks for your reply. Is it possible to transmit and receive data through SC16IS752 alone?. If it so, i do not have to use MAX487 and PIC controller which saves more space in my PCB.
_________________
Thanks & Regards,
Heavenlyrider.
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Sat Mar 05, 2016 5:22 am     Reply with quote

The smallest solution (by a large amount), would be to use a small PIC, with a MAX485. Choose one with hardware I2C, and a hardware UART. You'd need two pins for the I2C, two pins for RX/TX, one pin for the RS485 control, and one pin to set the 'address'. Now there are 'sneaky' ways that you can set the address with two jumpers using one pin. A search here will find suggestions (unfortunately if you use say the 12F1840, pin A3, doesn't support the ADC, but there are still ways of doing this).

The SC16IS752 is huge (28pin package), and needs the external transceiver as well. You also then have to solve how to address the devices.
heavenlyrider



Joined: 04 Mar 2016
Posts: 7
Location: India

View user's profile Send private message

PostPosted: Sat Mar 05, 2016 5:42 am     Reply with quote

Hi,

Thank you for your prompt response. I will try your suggestion.
_________________
Thanks & Regards,
Heavenlyrider.
temtronic



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

View user's profile Send private message

PostPosted: Sat Mar 05, 2016 8:04 am     Reply with quote

When choosing a PIC be sure to LOOK at the pinout ! Several PICs 'share' the UART and I2C pins, so you can use one or the other NOT both hardware peripherals. That's why I like to use a 'big' PIC as it can be easily used in future projects. Having a 'common' PIC means you gain a lot of knowledge on that PIC. While it might cost you a bit more now, you can make one PCB , use it in several projects. If you value your time, it's actually cheaper !
If you choose a PIC with shared UART/I2C then you have to decide whether to use it for UART or I2C. Since the temp sensor is I2C, I think the SW I2C for the PIC is good, allowing the HW UART to be used for RS485 communications.

options, always think of options


Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Sat Mar 05, 2016 8:58 am     Reply with quote

On the 1840, the UART is movable to avoid the I2C pins.
The only difficulty is providing an address.

The sort of 'trick' I was thinking of, was a 'pull down' diode from the I2C data pin, with a series resistor of 4K7 (this way the capacitor at the other end, won't significantly affect I2C), and having the two jumpers setting pull-up resistors, of perhaps 47K and 100K, with another fixed one of 200K. Then having A3 connected to the diode/resistor, the junction of the jumpers, and a capacitor. Then on start up, set the I2C line low, wait a few mSec, then release it, then time when A3 is seen to go high. The A3 pin has a Vih of 0.8Vdd, so 4v, for a 5v PIC (you don't say whether you are using the 5v or 3v sensor). The diode and resistor will pull the capacitor down below 1v. When released it'll charge up through 200K (no jumpers), to 27.5K (both jumpers). The time taken to see 'high' will depend on the jumper setting, and capacitor chosen. The range is large enough to allow 2 bits very easily, even given the low accuracy of typical capacitors. This then gives you four bus addresses.

Keep your protocol simple. Use just '1', '2' etc., for the address, and if you only want the temperature just use something like master selects bus, sends 'Tx<LF>', releases bus. Slave selects bus, and responds, 'Txnnn<SUM><LF>', where 'x' is the unit to use, 'nnn', is the reading from the chip in hex, <SUM> is a single byte sum of the previous bytes, and <LF> is a line feed. Then releases bus. If the sum doesn't match, you know to reject the value and try again.

Since the unit actually returns temperatures to 0.01C, but only gives an accuracy of 0.2C (and this only the high accuracy version), I'd only send the top 12bits of the value returned.

Obviously you have to make a decision whether to return the processed data, or the raw values (more data for the latter, but more flexibility possibly), and whether to allow control of other parameters.
temtronic



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

View user's profile Send private message

PostPosted: Sat Mar 05, 2016 4:14 pm     Reply with quote

I think the 16F1826 is a better chip for this purpose, it's only 30 cents more and would give easy hardware (jumper) programming of the slave addresses.

Obviously have to download the datasheets and confirm if it's possible. Having a few extra pins for only pennies more is usully a good thing !

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 4:46 am     Reply with quote

I agree, but it is larger. I was describing the smallest route. Very Happy

In fact though, if the chip is SMD, the extra size is tiny, and (of course) using the internal pull-ups, you would save the space for pull up resistors and not need the capacitor. The joke is the entire circuit will probably be smaller than the connectors needed....
temtronic



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

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 7:53 am     Reply with quote

I keep looking at 'clever' ways to address the addresses, too bad RA3 didn't go to the ADC... Any real hardware option gets 'complicate' both in components and software so a bigger PIC looks better( easier)
Best seems to 'hard code' within the program an slave address though it means every PIC will be different if you need an itty bitty module.
That of course brings up the power supply requirements....interesting 'can of worms'.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 8:01 am     Reply with quote

Yes.
I was thinking that with RS485, he could use your solution of using ethernet or telephone cable, and put power down an extra pair.

On the ID, the other very easy way, would be to have a single 'learn' jumper on A3, and if this is made, have the unit accept a RS485 command telling it what ID to use. Then you'd just have to attach each unit in turn with this made.
temtronic



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

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 8:22 am     Reply with quote

Looking at the original post, if he could use another temperature sensor,say a DS18B20P or even an LM34 he could eliminate the RS485 and slave PICs altogether ! 20m is about 70' and I've used LM34s that far so the digital DS chip would be fine. Also it allows a simple 2 conductor cable to be used,saves space,connectors,etc.

lots of options IF another sensor can be used.

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19568

View user's profile Send private message

PostPosted: Sun Mar 06, 2016 9:08 am     Reply with quote

The chip he is using, is a thermopile, not a conventional thermometer. Other equivalent devices are much larger and more complex. I've used thermopiles before, and it is nice to see one that is this simple.
temtronic



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

View user's profile Send private message

PostPosted: Mon Mar 07, 2016 6:53 am     Reply with quote

yeesh, they packed a LOT of neat tech into a TO-39 can! It can't be a cheap device so I'd spend a little extra and buy a 'bigger' PIC as I know the client will want another feature or a 'tweak' of the code once the PCBs are made.
Last TO-39 can I used had a SPST push button switch in it ! Times have changed in 30+ years.

Jay
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon Mar 07, 2016 7:42 am     Reply with quote

Hi All,

Networked IR temperature sensors??? Not an impossible scenario, but not too likely either. My guesses are (1) the OP hasn't a clue about this temperature sensor, and (2) this has nothing to do with CCS 'C'! The OP undoubtedly parachuted into the forum via a Google search.....
_________________
John

If it's worth doing, it's worth doing in real hardware!
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 1, 2  Next
Page 1 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