View previous topic :: View next topic |
Author |
Message |
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Wed Jul 13, 2016 3:43 am Post subject: TWI or SPI range with level shifter? |
|
|
Hi,
did anybody test TWI or SPI with a level shifter (like RS232 chip TX/RX)?
If so, what was the range (distance)?
Reason I ask is, I want to use TWI or SPI for temperature reporting for air and floor in all the rooms.
Serial coms are too hard to handle if there are 5 or 6 to serve.
RF is not too great, it would need encrypting the data transmission.
Please let me know about your success or failure.
Thanks
Hubert
(BASCOM-AVR version : 2.0.7.9 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Jul 13, 2016 6:47 am Post subject: |
|
|
I may believe it could work to use for example a MAX232 for unidirectional signals of SPI, but not for TWI, as both, SCL and SDA is bidirectional, especially SDA, while also SCL can be influenced by the slave, keyword clock-stretching. SPI however is a fast serial connection, making it prone to spikes and noise, which can sneak in also with level shifted signals. An UART is more insensitive in this matter, also I don't see the benefit in using level shifters in a star-like topology. In local SPI it's easy, CE controls which chip responds, the others chip pins are in Z-state, but if you connect all your MAX232's TX together, you'd need an additional line to enable only the addressed MAX232. But then, you have lots of long wire constantly connected, bad for line capacity. My conclusion, it's a bad idea. |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Wed Jul 13, 2016 9:42 am Post subject: |
|
|
Thanks for the reply.
Thinking of the involved selection (got to think of it after posting).
I will probably try ULN2004 with open collector with SPI at a very low frequency of maybe 125000Hz (1MHz/eight).
Powering with 12VDC. The speed is not needed for climate control.
Even at that low speed, I do not think that 3-5V SPI or TWI would be capable of 15 to 20 meters range (110 baud might do it).
The ULNs would allow for a high ma termination.
Just try to get all the control boards made for the move to Austria (new house).
Thanks again.
Hubert
edited because of smile instead of number eight. |
|
Back to top |
|
|
EDC
Joined: 26 Mar 2014 Posts: 971
|
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Wed Jul 13, 2016 12:07 pm Post subject: |
|
|
I would do a proprietary kinda one-wire protocol, only one line terminated, and GND.
The master initiates a request for values by pulling the line low for say 300ms. Each slave has its unique serial number and listens for the line pulled low, say for 300ms, also each slave knows it's order, when to respond, 1st, 2d, 3rd.
Every number's duration is a bit more of the multiple of the protocol transmission time, if the protocol takes 100ms, the 2nd slave responds after 150ms, avoiding blockade.
The protocol would contain the slaves order number, serial number and temperature value, I would use Manchester-encoding, as it also provides the clock.
To do remote programming of the slaves, change order-number, a.s.o. the line could be pulled low for 600ms, then each slave would listen for its serial number, and if found matching, accepts and stores new values, which the master sends.
The benefit of such a protocol would be:
- only 2 lines for all sensors
- timing as slow as desired
- adaptable to own requirements
Otherwise standard 2-wire devices could be an option. |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Wed Jul 13, 2016 5:17 pm Post subject: |
|
|
@EDC,
I do not understand enough Polish to make a lot of sense of it. Thanks anyway.
@MWS,
that seems a very good solution to me, because time is really not a problem (environment does not change fast).
With an Atmega1284 as master, I have enough lines available to do almost any type of communication for the eight slaves, 4x4 keypad and LCD.
Very practical.
Thanks again for a great solution.
Hubert |
|
Back to top |
|
|
laborratte
Joined: 27 Jul 2005 Posts: 299 Location: Berlin
|
Posted: Thu Jul 14, 2016 1:32 pm Post subject: |
|
|
There are chips for using TWI over long distances: P82B96 or PCA9605 from NXP. See Application Notes AN11084, AN10658 from NXP for details.
I investigated this about 10 years ago for a project where I needed (a bit more complex) communication between "nodes" with 10..30m distance.
And ended up with bidirectional RS485 and a simple hand made protocol.
But if you want to keep up with times you should use for every sensor multicore ARM based controllers with Linux, connected via WIFI to "The Cloud" |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Thu Jul 14, 2016 11:32 pm Post subject: |
|
|
@laborratte,
thanks for your mention of the chips. That would certainly reduce the work and I can implement them in the circuit boards.
Concerning the "cloud". I purposely stay away from the net for our house control. There will also be keyless entry,
another reason not to be hacked into the control. That is also the reason I do not do any cell phone (hand) banking.
Will stick to the old fashioned in this case.
Will consider it with the board design.
Thanks again
Hubert |
|
Back to top |
|
|
hgrueneis
Joined: 04 Apr 2009 Posts: 902 Location: A-4786 Brunnenthal
|
Posted: Fri Jul 15, 2016 6:04 am Post subject: |
|
|
@laborratte,
finally decided to use TWI on P82B96TD (so8). PCA9605 is obsolete and not available at Mouser any more.
According to the datasheet, the safest way is, to stay under 400K. Not a problem for this application.
That makes me happy, because I do not have to spend any extra time on programming.
In the applications they show systems for 200 to 300 meters range.
Twisted pair phone cable is recommended.
Thank you all for making this easier for me and to be able to continue with the board design in a hurry.
It really is an advantage to use TWI or SPI for me because I already did a lot of communication in this way between MCUs
with masters and slaves.
Special greetings to Berlin, spent some years there.
Also thanks to Mark Alberts for a great BASCOM! Without it we would still be in the beginnings.
Thank you all again.
Hubert |
|
Back to top |
|
|
|
|
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 You cannot attach files in this forum You cannot download files in this forum
|
|