|
|
View previous topic :: View next topic |
Author |
Message |
temtronic
Joined: 01 Jul 2010 Posts: 9106 Location: Greensville,Ontario
|
|
Posted: Sun Jan 21, 2018 4:54 pm |
|
|
Although it's an I2C device, it has a fixed address so you'll need to decide on 1 of 2 options
1) Big PIC and use 12 pairs of pins for each of 12 sensors.
2) Use an I2C mux, or 2 or 3. I don't know if a 12 channel exists.
Since you need 24 pins(+pwr,gnd) #1 seems OK. I do that for temp sensors like DS18B20s. You just copy the driver 12 times. That could be an issue depending on how much code the device needs.
Using a mux would allow ONE driver but you need to preselect the device,then access it. That's easy IF there's a 12 channel or 16 channel I2C mux available. It'll get a bit messy if you need say 3, 4 channel muxes.
Keep in mind board layout, power supply noise,etc. Also speed #1 means software I2C operations, #2 uses the HW I2C peripheral of the PIC.
Jay |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 452 Location: Montenegro
|
|
Posted: Sun Jan 21, 2018 9:18 pm |
|
|
It has a programmable i2c address, that defaults to 0x52 on each reset. It also has an input that shuts down the module. So I was thinking of
a) assigning each device it's own address on reset
b) keeping only one active device at any time and collect the data from it using generic address.
At any rate, I'd need 12 pins to control them and of course i2c, so any 40 pin PIC is plenty big enough, including the periphery. The time is not a problem, if I get the result every 15 seconds is OK. As for the code size, right now it uses 25% of code memory and less than 10% of RAM on 18f252.
Noise might be a problem, since the wires will be up to 60cm long. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9106 Location: Greensville,Ontario
|
|
Posted: Mon Jan 22, 2018 11:05 am |
|
|
re:
It has a programmable i2c address, that defaults to 0x52 on each reset
Yeesh, that's plain silly! Just HOW would you deal with that. Product gets reset for any reason ans 12 sensors are all 0x52 ! You couldn't program them !
I haven't read the datasheet,kinda glanced at it but not having a 'hard' address is ,well, scary. I saw it didn't have hardware addressing,like most I2C devices, so that's why a big PIC,2pins per sensor seemed a better solution.
edit: I downloaded ST AN4846 which outlines the PITA method to program a different I2C address. Of course they don't say if this is 'permanent' and wil be reset if the device is reset.NOT very conforting to say the least. Perhaps it's explained in the API manual ?
With needing 12 reset pins and an expander or two( 12 devices) it'd be a whole lot simpler to add 12 chnls of I2C expansion ! You'll save PCB space and SW will be EASY.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19221
|
|
Posted: Mon Jan 22, 2018 11:41 am |
|
|
If you read the data from ST, they recommend having the reset lines individually controlled, or using an I2C bus multiplexer. The latter is easy, and code for one was published here only a few weeks ago.
Honestly is the easiest way. |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 452 Location: Montenegro
|
|
Posted: Mon Jan 22, 2018 12:44 pm |
|
|
The potential losing of i2c address is the reason I'll try to use the method with XSHUT pin, without changing the addresses. And then just reuse the code to read them one after another. Of course I'll waste some time with initialization each time, but as I said, time is not critical. I can't verify that approach works, since I only have one sensor at the moment and I'm still waiting for the others to arrive. In theory it should, that is the way ST suggests to change the addresses in multi sensor system.
P.S. on different forums I saw that HIGH pulse on XSHUT resets the device. Maybe its just my module, where pulling it LOW resets it. If anyone tries to use the code, make sure to reverse the reset sequence if something doesn't work.
Regards, Samo |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19221
|
|
Posted: Mon Jan 22, 2018 2:32 pm |
|
|
No, it means the other people have something different about their hardware. Either an inverter programmed in the output or something similar. The data sheet is quite specific:
Quote: |
5 XSHUT Digital input Xshutdown pin, Active LOW
|
Active low.
The lowest chip count/simplest solution, is to use a 4-16 demultiplexer. The 74HCT154 for example.
Five pins.
Connect it's outputs to the reset pins. It's data input to one PIC pin.
Set the chip number you want to program the address for on the address inputs, and then pulse the data pin low then high. Result just the one chip gets a reset. Now send the sequence to program the I2C address. Then pulse another address and repeat for each of the other chips. Easy and quick. Then you have 12 chips on the addresses you have set.
Remember with 12 devices (13 including the PIC) on the bus you will need lower I2C pull-ups than are commonly used. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9106 Location: Greensville,Ontario
|
|
Posted: Mon Jan 22, 2018 5:50 pm |
|
|
tried digging into this a bit further and found this...
...
The sensor’s 7-bit slave address defaults to 0101001b on power-up. It can be changed to any other value by writing one of the device configuration registers, but the new address only applies until the sensor is reset or powered off.
...
It seems silly to me that the new device address isn't stored in 'firmware'. Having to reprogram the device(12 in this case) every time power goes off is ridiculous although we do that for LCD modules to enter 4bit mode. Perhaps the time to reprogram 12 devices isn't as long as I think.Still...
Jay |
|
|
|
|
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
|