Generate clock and data signal for data output in attiny13

Go To Last Post
22 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HI everyone, first post here!

 

I'm planning to build a 50+ addressable 10k ohms pots. the idea is like ws2812 leds, i could query for the value of any of this pots individually, with a 2 wire interface (there is physical space constraint, as a reason to do it like that, i can't use more than 4 wires, 2 for data, 2 for power & gnd, and i can't connect them individually).

 

my idea is to hook up each of them to a attiny13 (not using any other like attiny85, for the cost, the attiny13 is the cheapest avr i could find), and then write the code that will receive and send commands through this clock & data signal interface, in binary format.

 

is the first time i want to use this kind of communication protocol, so i was wondering if someone could share any link about it, mostly in the arduino IDE format.

 

Thanks!

Last Edited: Tue. Mar 13, 2018 - 12:17 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ipsilondev wrote:

HI everyone, first post here!

Welcome.

 

ipsilondev wrote:

(not using any other like attiny85, for the cost, the attiny13 is the cheapest avr i could find)

? There are other AVRs cheaper than tiny13. 

 

ipsilondev wrote:

I'm planning to build a 50+ addressable 10k ohms pots. the idea is like ws2812 leds, i could query for the value of any of this pots individually, with a 2 wire interface (there is physical space constraint, as a reason to do it like that, i can't use more than 4 wires, 2 for data, 2 for power & gnd, and i can't connect them individually).

Do you mean you want to interleave with WS2812 parts, and use the exact same timing, (that's not going to be trivial..)

or

that you want some similar daisy-chain protocol ? 

eg The tiny102 has a UART block, and that makes ring designs easy to design and test from a PC host.

( go to Digikey - microcontrollers, and search for UART and sort by price, to see candidate UART included parts)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How do you propose to make the pot portion?  The avr has no pot, typically you might use a multiplying dac to do so.  Do you really need pot or something like one?  What are you requirements?  There are various postings regarding stringing together 1-wire  serial comms.   If you use 2 wires, why not simply use IIC/I2C hardware--built into every AVR.

When in the dark remember-the future looks brighter than ever.

Last Edited: Tue. Mar 13, 2018 - 01:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Who-me wrote:

ipsilondev wrote:

HI everyone, first post here!

Welcome.

 

ipsilondev wrote:

(not using any other like attiny85, for the cost, the attiny13 is the cheapest avr i could find)

? There are other AVRs cheaper than tiny13. 

 

ipsilondev wrote:

I'm planning to build a 50+ addressable 10k ohms pots. the idea is like ws2812 leds, i could query for the value of any of this pots individually, with a 2 wire interface (there is physical space constraint, as a reason to do it like that, i can't use more than 4 wires, 2 for data, 2 for power & gnd, and i can't connect them individually).

Do you mean you want to interleave with WS2812 parts, and use the exact same timing, (that's not going to be trivial..)

or

that you want some similar daisy-chain protocol ? 

eg The tiny102 has a UART block, and that makes ring designs easy to design and test from a PC host.

( go to Digikey - microcontrollers, and search for UART and sort by price, to see candidate UART included parts)

 

 

Thanks for the suggestion, you are right, tiny102 is a lot cheaper! 

 

To clarify, no, i don't connect any ws2812, my mention about it, was just a comparison of how i will connect the pots (in a daisy-chain protocol scheme, i didn't know that term existed :) ).

 

 Anyway, i'm still in need of how to generate the square wave for the clock signal and send data. i suppose that attiny102 doesn't support arduino IDE right?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm hooking up a BK10 pot to the attiny, then sending the value through the daisy ring to the master (an arduino mega). your suggestion is actually right, i could use i2C with attiny13. not with the attiny102 tough (not a deal breaker, just figuring out what to do really).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The only way to have 50+ potentiometers connected with four wires, and have the ability to read the value on each pot is to have a cheap microcontroller connected to each pot.  Then each microcontroller has to be connected as a I2C slave device that shares Vcc, ground, SDA, and SCL lines with all the other microcontrollers and a single master I2C microcontroller.

  Because the Tiny13 has only 1K of flash and no I2C control peripheral control circuitry, you will need to write an I2C slave routine in AVR assembler that "bit-bangs" the SCL and SDA lines.   Each tiny13 will have a unique I2C slave address stored in either its EEPROM or flash. 

  The master will send a SLA+Read byte over the I2C bus that will be seen by all the Tiny13s.  Only one of them will issue an Acknowledgement pulse in reply.  Then the master CPU will send the  SCL clock pulses and the addressed slave will either assert or release the SDA line for 8 bits.  In theory, since the Tiny13 has a 10-bit ADC, it could send a 10-bit ADC response of the pot's angle position. But, why complicate things?  After the slave Tiny13 sends the pot value, it releases the SDA in order to create a Non-Ackowledge signal, which lets the master know that the entire I2C message is completed and the I2C bus has been released by the slave.

   The only application that I could imagine for such a hardware configuration would be as a controller for a MIDI music synthesizer/tone module, where 50 parameters of the final "patch" or sound would be individually controlled by a unique potentiometer adjustment.

   It would be better to use a single TFT 320x240 pixel screen with a built-in touch screen.  The top 4/5ths of the display would have 50 or so numbered squares (7 rows of 8 squares) and the bottom 1/5th of the screen would be a virtual potentiometer with the zero value on the left and the max virtual pot setting on the right.  The user would first press one of the squares to select the "pot", then press a position on the left/right axis along the bottom of the screen for this virtual pot's value.  This would be much cheaper: $3 for the Arduino Nano controller and $7 for the TFT/touch screen vs. 50+ pot/Tiny13 combinations at @$1.30 each; or @$70 in parts cost.

  'Fess up! Is this some kind of school project?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm planning to build a 50+ addressable 10k ohms pots

I assumed you are trying to create remotely programmable pots for running led drivers (you mention ws2812)...but you also mention reading the pots...please clarify.  On the other hand, this seems like you may be simply trying to red 50 knobs with a pot connected to an adc/serial converter.

 

Here is a complete 1-wire project with some Bascom code, that might have some interest:

https://www.mcselec.com/index.php?option=com_content&task=view&id=256&Itemid=57

 

    

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

I'm planning to build a 50+ addressable 10k ohms pots

I assumed you are trying to create remotely programmable pots for running led drivers (you mention ws2812)...but you also mention reading the pots...please clarify.  On the other hand, this seems like you may be simply trying to red 50 knobs with a pot connected to an adc/serial converter.

 

Here is a complete 1-wire project with some Bascom code, that might have some interest:

https://www.mcselec.com/index.php?option=com_content&task=view&id=256&Itemid=57

 

    

 

Sorry for the miscommunication, there is no ws2812 involved.  is only 50+ pots connected in a serial way, thanks for the link, i will check it out.

 

Simonetta wrote:

The only way to have 50+ potentiometers connected with four wires, and have the ability to read the value on each pot is to have a cheap microcontroller connected to each pot.  Then each microcontroller has to be connected as a I2C slave device that shares Vcc, ground, SDA, and SCL lines with all the other microcontrollers and a single master I2C microcontroller.

  Because the Tiny13 has only 1K of flash and no I2C control peripheral control circuitry, you will need to write an I2C slave routine in AVR assembler that "bit-bangs" the SCL and SDA lines.   Each tiny13 will have a unique I2C slave address stored in either its EEPROM or flash. 

  The master will send a SLA+Read byte over the I2C bus that will be seen by all the Tiny13s.  Only one of them will issue an Acknowledgement pulse in reply.  Then the master CPU will send the  SCL clock pulses and the addressed slave will either assert or release the SDA line for 8 bits.  In theory, since the Tiny13 has a 10-bit ADC, it could send a 10-bit ADC response of the pot's angle position. But, why complicate things?  After the slave Tiny13 sends the pot value, it releases the SDA in order to create a Non-Ackowledge signal, which lets the master know that the entire I2C message is completed and the I2C bus has been released by the slave.

   The only application that I could imagine for such a hardware configuration would be as a controller for a MIDI music synthesizer/tone module, where 50 parameters of the final "patch" or sound would be individually controlled by a unique potentiometer adjustment.

   It would be better to use a single TFT 320x240 pixel screen with a built-in touch screen.  The top 4/5ths of the display would have 50 or so numbered squares (7 rows of 8 squares) and the bottom 1/5th of the screen would be a virtual potentiometer with the zero value on the left and the max virtual pot setting on the right.  The user would first press one of the squares to select the "pot", then press a position on the left/right axis along the bottom of the screen for this virtual pot's value.  This would be much cheaper: $3 for the Arduino Nano controller and $7 for the TFT/touch screen vs. 50+ pot/Tiny13 combinations at @$1.30 each; or @$70 in parts cost.

  'Fess up! Is this some kind of school project?

 

no, this is not a school project, i use the pots as sensor to detect the rotation of several elements attached to it, that's why the arrangement. i know that the cost is high, trying to reduce it as much as i can (to make it worse, i'm in south america, so shipping is up to $40usd + customs (50% duty tax), that's why i'm asking to consolidate my theory, why the cost to get it is even higher for me)

 

you are right, but also, i was thinking to implement a "simpler" protocol (mostly to avoid doing asm if possible, i'm more comfortable with C), let me know what do you think about this:

 

 

On initialization:

 

On boot, all attiny, will listen on PB0, for amount of X high inputs, with a timeout after the last HIGH signal. the amount of HIGH's minus 1, will be the address assigned to it. When timeout happens, it will use PB3, to forward the amount of HIGH + 1 to the next attiny (wired to PB0)

 

On Use:

 

Append: using always a first high and a delay to notify the next attiny or master, that data is coming in, on PB0 or PB3.

 

1) Listen on PB0, first high, delay 100ms, then use a fixed clock (let's say 50ms) to read PB0, and get the 4 bit value, representing the address to query.

2) If address query match, send first high, delay 100ms, and then it will return the 10 bits on the same fixed clock, usign PB0.

3) if address doesn't match, send first high, delay 100ms, it will forward the 4 bit query to the next attiny on PB0, using PB3.

4) If receive a HIGH on PB3, means data input, wait delay, receive the 10 bit on fixed clock, forward to the next attiny or master with PB0

 

Like all attiny's are on the same mhz, i think the fixed clock technique would work, except for the master (arduino mega, 16mhz) where i suppose i would need to compensate the difference. i don't need this to be extremely fast, so i can actually make a big clock window to read / forward the value and make delays between each if is needed, to avoid any data collision in the synchronization. plus is a 3 wire only system (vcc, gnd, data (connected on PB0 on one side, PB3 on the other side)

 

i know that this is not fast, is not async, and it forcing to use like a cascade schema on the attiny, but i believe that is simpler to use, it will get me the value of any pot individually and it will allow me to use attiny102 that is even cheaper than attiny13, with less code.

 

Any toughs / feedback about this idea?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Each AVR has from 4 to 8 or more ADC channels each, are the "pots" spread out so far apart that a larger AVR  that senses more then one pot not more cost effective then 4x to 8x smaller AVRs? 

 

 

I would also consider using a rs-485 bus rather then a daisy chain of micros.

 

Jim

 

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:
rs-485 bus

 

The spread vary, from 20cm to 100cm, the thing is that is also modular. i should be able to connect, 5, 20, 28 or 50 on the array. and also quick (i can't be soldering to build the array, must be plug & play). 

 

Thanks for the rs-485 bus, looks like an alternative, but i would need to add a MAX485 to each avr, resulting in more cost.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ipsilondev wrote:

ki0bk wrote:
rs-485 bus

 

The spread vary, from 20cm to 100cm, the thing is that is also modular. i should be able to connect, 5, 20, 28 or 50 on the array. and also quick (i can't be soldering to build the array, must be plug & play). 

 

Thanks for the rs-485 bus, looks like an alternative, but i would need to add a MAX485 to each avr, resulting in more cost.

At that distance you will find the differential signaling will be needed for reliable comms!  Industrial plants all over the world use 485, no soldering required.

Good luck.

 

Jim

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

Last Edited: Tue. Mar 13, 2018 - 02:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

ipsilondev wrote:

ki0bk wrote:
rs-485 bus

 

The spread vary, from 20cm to 100cm, the thing is that is also modular. i should be able to connect, 5, 20, 28 or 50 on the array. and also quick (i can't be soldering to build the array, must be plug & play). 

 

Thanks for the rs-485 bus, looks like an alternative, but i would need to add a MAX485 to each avr, resulting in more cost.

At that distance you will find the differential signaling will be needed for reliable comms!  Industrial plants all over the world use 485, no soldering required.

Good luck.

 

Jim

 

 

I was referring about soldering, for the suggestion of putting more pots per avr. I don't discard rs-485, i would try to do it whiteout it at first tough.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think 100 cm isn't too far for 1wire, which has been implemented multiple times for avr. Needs only 1 wire + power: gnd, vcc, data.

 

Google is your friend.

 

You might even get this all to work with parasitic power, and need only two wires: gnd + data/vcc.

 

What kind of data rate do you require? How often do you need to poll each sensor for a value?

 

 

EDIT: sp

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"Read a lot.  Write a lot."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

Last Edited: Tue. Mar 13, 2018 - 03:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 i use the pots as sensor to detect the rotation of several elements attached to it

Note, if the pots are constantly moving, you will need to consider wear & tear....some types of pots won't last long...other such as used in throttle sensing will last very long.

 

How fast/often do you need to read...what latency can you live with (10us, 1ms , 100ms, 1minute?).

 

You can use slow serial com at long distances quite easily, taking average of the rcvd signal to filter noise...that is what makes it slow...is your app in a noisy environment?

 

What pot are you using (provide link)

 

 

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sounds like a robot application, now that I think about it, a one wire solution may be the best solution after all.  Would have been nice if the OP had said what the application was.

 

Any way, good luck with the project and report back your progress.

  

 

Jim

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I still think that I2C is the best approach because I2C is specifically designed for this kind of application: 50+ identical modules connected together.   With a project of this size, the planning stages always make the solution seem straightforward.  However the final implementation brings many unforeseen problems and difficulties.  For that reason, I suggest not using a simple and inexpensive specialized microcontroller. 

 

   Instead I would use the Arduino Pro Mini board.  These boards are mass-manufactured by the 10,000s, which gives economies-of-scale to the basic hardware design.  They can be purchased from China through eBay or AliExpress for about $2.50 USD each.  The Pro Mini uses an AVR Mega328P, which has I2C hardware built into its circuitry.   In a project like this, I recommend using standardized hardware and downloadable tested library code, because it will be one less thing that will go wrong and require hours of debugging.  The developer's focus should be on the application: not the hardware or low-level software implementation.  The Arduino Wire.h library for I2C has proven tested routines for I2C slaves.  As there are thousands of Arduino developers worldwide, it will be easier to get help on the web when the final circuit fails to work as it was designed to do in the planning stages.  In addition, all the extra Pro Mini boards not used for this application can be used in future projects.  And it will be cheaper to hire future technical employees because Arduino is a world standard that is studied by everyone (more-or-less) in the embedded-systems industry.  If you buy of quantity of 100 Pro Mini boards, you could get a discount that would bring the price of each Pro Mini to near the cost of the combination of an AVR tiny13 (or tiny102), an RS485 interface IC, and a custom printed circuit board.

 

  An RS485 "daisy chain" could quickly become a big mess if one stage fails to work exactly correctly.  This will overwhelm your technical support staff.  And a customized design will be much more difficult to repair in the future when everyone has forgotten how the system operates.  At some point, one single module will fail and the entire daisy chain will stop working.  It might be difficult to determine which is the one module that has failed.  Like one bad bulb in a string of Christmas lights that causes all the lights to be off.  With I2C, the module that failed is the module that didn't acknowledge its individual slave address.

Last Edited: Tue. Mar 13, 2018 - 04:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On boot, all attiny, will listen on PB0, for amount of X high inputs, with a timeout after the last HIGH signal. the amount of HIGH's minus 1, will be the address assigned to it. When timeout happens, it will use PB3, to forward the amount of HIGH + 1 to the next attiny (wired to PB0)

 for amount amount of X high inputs????   WHAT?  If you want help, please write something that's useable 

When in the dark remember-the future looks brighter than ever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First of all, many thanks for all your suggestions and support, has been really helpful.

 

joeymorin wrote:

I think 100 cm isn't too far for 1wire, which has been implemented multiple times for avr. Needs only 1 wire + power: gnd, vcc, data.

 

Google is your friend.

 

You might even get this all to work with parasitic power, and need only two wires: gnd + data/vcc.

 

What kind of data rate do you require? How often do you need to poll each sensor for a value?

 

 

EDIT: sp

 

the vcc + gnd + 1 wire protocol is the goal for now. worst case scenario, i will upgrade to rs-485. i will pull out the value, every 10 minutes max.

 

avrcandies wrote:

 i use the pots as sensor to detect the rotation of several elements attached to it

Note, if the pots are constantly moving, you will need to consider wear & tear....some types of pots won't last long...other such as used in throttle sensing will last very long.

 

How fast/often do you need to read...what latency can you live with (10us, 1ms , 100ms, 1minute?).

 

You can use slow serial com at long distances quite easily, taking average of the rcvd signal to filter noise...that is what makes it slow...is your app in a noisy environment?

 

What pot are you using (provide link)

 

 

 

i consider the wear and tear factor, but for the first prototype, i will just use B10K pots , this is not moved by a motor, but manually, so i suppose they will last enough for what i paid for (BK10 pots are dirt cheap). Latency could be opt to 1sec per query if is needed (ideally i would like it to make it at 500ms, mostly why this is multiplied by the amount of elements in the array.

 

ki0bk wrote:

Sounds like a robot application, now that I think about it, a one wire solution may be the best solution after all.  Would have been nice if the OP had said what the application was.

 

Any way, good luck with the project and report back your progress.

  

 

Jim

 

 

Sort of, i'm using the pots plus pre-defined pieces of specific length to map movement and structure in a virtual 3D space. is not moved by motors, is moved manually btw.

 

I will share the open source code of the avr slave's, arduino master and schematic as soon i get it done ! (i just ordered the attiny102, so i will get them in about a week or more with the courier shipping).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
using standardized hardware
  +1

 

I like that idea, although depending on the size of the robot, may not fit in the space available....

 

I too keep a promicro + promini on my workbench for such things (note it's the promini with the M328)

 

Jim

 

Mission: Improving the readiness of hams world wide : flinthillsradioinc.com

Interests: Ham Radio, Solar power, futures & currency trading - whats yours?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:

I still think that I2C is the best approach because I2C is specifically designed for this kind of application: 50+ identical modules connected together.   With a project of this size, the planning stages always make the solution seem straightforward.  However the final implementation brings many unforeseen problems and difficulties.  For that reason, I suggest not using a simple and inexpensive specialized microcontroller. 

 

   Instead I would use the Arduino Pro Mini board.  These boards are mass-manufactured by the 10,000s, which gives economies-of-scale to the basic hardware design.  They can be purchased from China through eBay or AliExpress for about $2.50 USD each.  The Pro Mini uses an AVR Mega328P, which has I2C hardware built into its circuitry.   In a project like this, I recommend using standardized hardware and downloadable tested library code, because it will be one less thing that will go wrong and require hours of debugging.  The developer's focus should be on the application: not the hardware or low-level software implementation.  The Arduino Wire.h library for I2C has proven tested routines for I2C slaves.  As there are thousands of Arduino developers worldwide, it will be easier to get help on the web when the final circuit fails to work as it was designed to do in the planning stages.  In addition, all the extra Pro Mini boards not used for this application can be used in future projects.  And it will be cheaper to hire future technical employees because Arduino is a world standard that is studied by everyone (more-or-less) in the embedded-systems industry.  If you buy of quantity of 100 Pro Mini boards, you could get a discount that would bring the price of each Pro Mini to near the cost of the combination of an AVR tiny13 (or tiny102), an RS485 interface IC, and a custom printed circuit board.

 

  An RS485 "daisy chain" could quickly become a big mess if one stage fails to work exactly correctly.  This will overwhelm your technical support staff.  And a customized design will be much more difficult to repair in the future when everyone has forgotten how the system operates.  At some point, one single module will fail and the entire daisy chain will stop working.  It might be difficult to determine which is the one module that has failed.  Like one bad bulb in a string of Christmas lights that causes all the lights to be off.  With I2C, the module that failed is the module that didn't acknowledge its individual slave address.

 

i totally agree, actually, this is usually my approach, but on this case, anything more than $1usd per piece is too expensive (my budget can't support $250 usd in arduino only). i'm not planning to sell or mass produce this for now, i still need to try to see if actually does what i need (is not my first iteration, i tried other non-electronic based methods that didn't work out for a tons of reasons that has nothing to do with this). is not a short project, is a six month project between building electronics, software, testing, etc.. just to have an alpha version working. i'm just starting this iteration trying the electronics approach, so i have a long way to go :)

 

avrcandies wrote:

On boot, all attiny, will listen on PB0, for amount of X high inputs, with a timeout after the last HIGH signal. the amount of HIGH's minus 1, will be the address assigned to it. When timeout happens, it will use PB3, to forward the amount of HIGH + 1 to the next attiny (wired to PB0)

 for amount amount of X high inputs????   WHAT?  If you want help, please write something that's useable 

 

i'm sorry, i wasn't trying to offend you or the community. just trying to share what comes out of my mind to solve the problem at hand. like others and you pointed out, i know is not the perfect solution, i can perfect it later in a next iteration if is needed. or not. that's why i share my plans, even if is not flawless, to compare, discuss, learn and make things better :)

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry, i wasn't trying to offend you or the community. just trying to share what comes out of my mind

That's good, sometimes posters wonder why it's hard to give a solution to such things.

 

 

Here is an easy idea to try:

 

Establish 4 widely different timings that won't be confused due to noise. Say 1/2ms, 1ms, 2ms, 4ms, corresponding to 0,1, bitgap (BG), command block (CB).  BG & CB are low for the requiresd time, 0 & 1 are high for the required time.
Two serial lines used by each pot module: one incoming, the other outgoing.  Each of these two lines are shared between all the modules. The outgoing lines are all set as input (hi-z), unless a selected module has been requested to reply with a reading. 

All modules always listen & wait for a command block mark; once they detect command block, they are all ready to rcv commands. The pulse widths corresponding to ones and zeros & bitgaps are used to send an address request:  Say address 22 (010110)requested:

CB..0..BG..1..BG..0..BG..1..BG..1..BG..0  is sent by the master.

The listening modules decode the address (by monitoring the timings) & after enough time has passed for all 6 address bits, module 22 set's it's output pin active and sends a reply (the pot value), using a similar format.  Since these times are "long" the signal can be sampled many times (20,50,100,etc) and "debounced" to eliminate any noise effects on the lines.  Of course the timings could be sped up to whatever is practical/useable.

You could have a special command to assign each module's address & store it in EEPROM, doing it one by one, before installation (say send address 63 command followed by a command containing the desired address to be stored).

 

Fan out/in limits would need looked at since tying 50 pins together might cause issues due to pin current leakages.  If that is an issue, a similar scheme could be used in a daisy-chain hookup, with much faster timings.

 

Note, the tiny201 seems to lack eeprom...could also hand-solder pins to set an address 
  

When in the dark remember-the future looks brighter than ever.

Last Edited: Tue. Mar 13, 2018 - 05:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ipsilondev wrote:
i know that this is not fast, is not async, and it forcing to use like a cascade schema on the attiny, but i believe that is simpler to use, it will get me the value of any pot individually and it will allow me to use attiny102 that is even cheaper than attiny13, with less code.

Sounds very slow over 50 units.

 

Choices would be i2c, which requires you set an address on every unit somehow, or a daisy chain ring design.

If you are ok with setting each address, i2c can be buffered to better tolerate longer cables.

 

 

With a daisy chain ring, each unit extracts N bytes of payload, after seeing some bit edge, and shifts that bit edge, so the next unit extracts the following N bits.

The physical position in the chain, is the address. Very simple with 9 bit UARTS, but also doable with 8 bit uarts.

 

You can even count and verify the unit on this bus, by sending 60 packets, the last 10 arrive back unmodified confirming 50 in the ring.

A simple link-watchdog can send out a 'nothing arriving' packet, and from that you can decide were a loop break may be. 

 

What is the total loop area/distance ? If this gets into tens of metres in a noisy environment, you could consider opto-isolation of some stages ?