Close
0%
0%

3-Wire Bus

This kind of bus is made up of one programmable Master - ATmega8 and 3 ( max. possible 255 ) Slaves - ATtiny13 parallel connected to master.

Similar projects worth following
This very simple and unconvetional bus contains one master and more than 2 slaves. The slave can be causing an event - a switch ( with a button ) or showing an event - an actuator ( with a LED ).
The behavior of slaves is programmed by master - the code is stored in its EEPROM.
It can be used for the development of low level control systems or as a base idea for HVAC.
There is a 2-Wire variant too, but it exceeds the 1kB condition.

BASIC PRINCIPLE :

Master generates an one-directional signal. The slaves use the signal as a data source and for power suply as well. The signal consists of all 256 8-bit characters coded in one 256-bits string which is repeatedly transmitted on the Signal wire in an infinite loop.

Hexadecimal expression of the string:
440C377B050919296DFE8385954C4D456B1A3A4E5C5E3C87CCD9DA7ABAFB9F80

There is a high "measure"-impulse between every two bits for the evaluation purposes and better power supplying capability.
So the string :
01000100...
looks like this practically:
0111010101110101...

The second wire is bi-directional and is called Response. It is low normally but it goes high when a switch is pressed in order to start the communication with master. If Response is already high that means there is an ongoing communication with another slave. The level is set low when the Slave_ID is found. If there is required a state change of an actuator, Response is set high by master immediatelly and remains high until the programmed Slave_ID ( actuator ) is found:

An example for Slave_ID 0x09 which causes a state change of Slave_ID 0x64. Response is driven high first by slave then by master.

Third wire is GND.

FUNCTIONS :

( currently ) three actuator functions can be assigned to the slaves:

- LED_On

- LED_Off

- LED_toggle

PROGRAMMING GUIDE:

The master's controller ATmega8 is connected to 2 x 2 digits 7-seg. displays. First 2 digits shows the EEPROM address, the second two digits the data stored at the displayed address. There are three buttons : +, - ( or Up and Down ) and Enter. It can be moved inside the entire EEPROM by + and -. The higher half - 100h to 1FFh is indicated by the decimal point. If Enter is pressed the stored data value can be increased or decreased by + and -. Enter pressed once more - new data is stored and the control goes back to the address. For the change from programming mode to operation mode it must be written 00h at the address 1FFh. Press + and - together to jump back to the programming mode. In operation mode is nothing displayed, except the decimal point when the Response is driven high.

At the address 1FFh the bus speed can be set - theoretically in the range of 01h to FFh ( but practically it makes sense only till 7Fh, above 80h it runs very slowly and the resolving process is not reliable ).

Following bytes are necessary for the functionality:

RangeUsage
000h - 006h7-seg characters*
007h - 02Fhconstants for the signal construction*
040h - 04FhChannels for the actuator functionality LED_On
050h - 05FhChannels for the actuator functionality LED_Off
060h - 06FhChannels for the actuator functionality LED_toggle
100h - 1FEhSlave_IDs where can be stored the pointers to function or the state (in case of actuator)
1FFh

00h - Entry point to Operation Mode, Range 01h - FFh = frequency change


1. Example:

given slaves - Switches : ID DDh, A5h Actuator ID 44h

to do : If the switch with ID DDh is pressed --> Actuator with ID 44h - LED_On, if the switch with ID A5h is pressed --> Actuator with ID 44h - LED_Off

Solution:

EEPROM settings : 040h - 44h, 050h - 44h, 1DDh - 040h, 1A5h - 050h. At 144h the current status of the actuator will be stored by master.

2. Example:

given slaves - Switch : ID DDh, Actuator ID 44h

to do : If the switch with ID DDh is pressed--> Actuator with ID 44h - LED_toggle

Solution:

EEPROM settings : 060 - 44h, 1DD - 60h. At 144h the current status of the actuator will be stored by master.

CONSTRUCTION DETAILS :

As written, Signal is generated by master and distributed by a single pin in this case. This project is presented with 3 slaves ( 2 switches and 1 actuator ) in order to fullfil the 1 kB limit but I've tested it with 8 slaves ( 5 switches and 3 actuators ) and it worked ok because all slaves are in Power-down. In case of more than 20 slaves it should be considered a power supply solution with better performance.

All codes can be assmbled by AVR/Atmel Studio.

MEMORY USE CALCULATION :

Master :

Slaves :

Switches DDh, A5h

Actuator

...summed up:...

Read more »

master.hex

HEX code for Master - ATmega8

hex - 1.55 kB - 04/24/2017 at 08:33

Download

master.eep

EEPROM content for ATmega8

eep - 223.00 bytes - 04/24/2017 at 08:33

Download

Slave_SW_DD.hex

HEX code for Switch Slave_ID DDh - ATtiny13

hex - 378.00 bytes - 04/24/2017 at 08:33

Download

Slave_SW_A5.hex

HEX code for Switch Slave_ID A5h - ATtiny13

hex - 378.00 bytes - 04/24/2017 at 08:33

Download

Slave_AC.hex

HEX code for Actuator Actuator_ID 44h - ATtiny13

hex - 476.00 bytes - 04/24/2017 at 08:32

Download

View all 8 files

  • 1 × ATmega8 Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 3 × ATtiny13 Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 2 × Kingbright DA56-11EWA 2 digits 7-seg. displays
  • 5 × Resistors 100 Ohm SMD R0805
  • 2 × Resistors 1k5 SMD R0805

View all 10 components

  • 1st update

    martin.klingac04/24/2017 at 08:50 0 comments

    I've updated the hex files in order to ensure more reliability during the resolving process. (..and it still fulfills the 1 kB limitation :-) )

    Important assumes :

    - Master : 8Mhz

    - Slaves : 4,8 Mhz

    - Drop the supply voltage to 3,3 V for a better performance.

    Next steps :

    - Master upgrade from 8 Mhz to 16 Mhz ( the XTAL pins – currently used as 7seg display drivers – should be used for an external 16 Mhz crystal )

    - Split the power supply – I would like to use more slaves and the power supply by a single pin wouldn’t be ok for the master

    - New functions – timer, switching more actuators,…

View project log

Enjoy this project?

Share

Discussions

Does this project spark your interest?

Become a member to follow this project and never miss any updates