PDA

View Full Version : I2C 8+8 expander with extra features



aratti
- 27th November 2008, 13:35
This project, based on pic16F876, was born as a simple 8+8 IOs expander because in industrial automation IOs are like bread.

Recently I have been requested to project a precision positioning machine with 3 axis and a spindle all driven with closed loop ac servo system (SanyoDenki)

I came to the conclusion that it was the right time to add extra features to the expander, in order to have a multi-purpose device, that I could also use for future applications.

I am posting, for sharing with the forum members and guests, a zipped file which contains the following:

8+8 IO expander.pdf (user manual & schematics)
I2C_Expander_2.hex (I2C address device # 2)
I2C_Expander_3.hex (I2C address device # 3)
I2C_Expander_4.hex (I2C address device # 4)

Hope you will find it useful

Al.

rmteo
- 27th November 2008, 16:32
Except for the stepper motor functionality you built into the 876, you could use an MCP23018 as an 8/16 bit I/O expander. No code, oscillator needed at about 1/3 the price.
http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en537375

Device Description 16-bit I/O Port Expander
Operating Voltage Range (V) 1.8 to 5.5
Operating Temp Range (°C) -40 to 125
Interface I²C™
Max. Bus Frequency (kBits/s) 3400
16-bit remote bidirectional I/O port
Open-drain outputs: - 5.5V tolerant - 25 mA sink capable - 400 mA total current out
High-speed I2C™ interface up to 3.4 MHz
Single hardware address pin: Voltage input to allow up to eight devices on the bus
Configurable interrupt output pins: active-high, active-low or open-drain
Low standby current:1 μA (typ.)

aratti
- 29th November 2008, 13:10
The profile algorithm transforms the travel command (steps) into three vector quantities:

Vector A Acceleration from rest to fixed speed (vector slope defined by ramp)
Vector B travel at fixed speed from end of vector A to begining of vector C
Vector C Deceleration from fixed speed to rest at target point (Vector A inverted)

This technique is known as "TRAPEZOIDAL PROFILE".

When the travel command is equal or less than vector A + vector B
the algorithm convert the trapezoidal profile into "TRIANGULAR PROFILE"
calculating new vectors A & B with different slopes as function of the given travel command

For small travel command (few steps) the algorithm was yielding incorrect sharp slopes that
could stall the motor if requested to turn at high speed.

The bug has been found and removed!

Now the motor turns smootly also with few steps travel command at high speed setting.

The new version software (IO_Expander_new) is attached, as a zipped file, to this post.

Ioannis
- 29th November 2008, 14:14
Great project! Congratulations and a big thank you for sharing your project with us.

I'd like to ask about the reliability of the I2C in the industrial environment. Is robbust enough to trust it in a place that are interference of every kind around?

I prefered to use the old classic SIPO and PISO chips and techniques, but I am willing to change into I2C if it is at least at the same level too.

Ioannis

aratti
- 29th November 2008, 14:31
Ioannis , I have more than 20 automations working with I2C installed in different places and all works pretty well. If you want give a try do it, providing that you optoisolate the digital part (inputs & outputs) from the external power devices (motor; valves; relays and sensors of any type).

Al.

Ioannis
- 29th November 2008, 23:04
Thanks for the reply.

I have some projects where the inputs are optoisolated, outputs are relays and analog drive directly the PIC inputs through some sort of zener diode protection.

For the digital part I use the Parallel input-Serial Output and the reverse, Serial Input-Parallel Output registers like the 4021 and 4094 or the A6841/MIC6841 that drives relays directly. Especially the latter is a good IC and drives relays with no need for other components. I wonder if there is an equivalent in I2C.

This registers need at least 5 lines for data-in, data-out, clock, strobe and load. That is why I think to jump into I2C.

Regards,
Ioannis