Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 10:34 28 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Help-Color Maxi+Freetronics relay driver

Author Message
zcontrol
Newbie

Joined: 14/09/2013
Location: Australia
Posts: 7
Posted: 10:23pm 29 Sep 2013
Copy link to clipboard 
Print this post

HI Folks,

I'm new to the maximite scene but have been playing in the retro computing scene for a while.

I am currently trying to use the color maximite to control a model railway both for input and output.

To help get things moving quickly, I invested in a Freetronics Arduino relay driver shield, plugged it into the maximite and have been trying to get it working to days with no luck.

The first problem I had was not realising I had to set the SCL / SDA jumpers on the maximite board.

Once I did that I could then send commands to the board via the I2CSend command and not recieve an error however, it does not appear that the board is actually doing anything. What I am expecting to see is a relay driver led come on when I send the corresponding relay code, but nothing.

To be honest I am completely stuck and not sure what to do from here.

The documentation for the board including sample C code can be found here:

http://www.freetronics.com/pages/relay8-8-channel-relay-driv er-shield-quickstart-guide

any help would be greatly appreciated and thanks in advance.
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 11:18pm 29 Sep 2013
Copy link to clipboard 
Print this post

Probably a good idea to include your code so that we can see what you are doing. Are you using a external supply as recommended.
Regards
Cliff
Cliff
 
zcontrol
Newbie

Joined: 14/09/2013
Location: Australia
Posts: 7
Posted: 12:10am 30 Sep 2013
Copy link to clipboard 
Print this post

Hi Cliff, since I am not currently driving any relays I am using the internal power supply and the plug pack is supplying 1.5amps at 9v, which is plenty.

As for the code:

10 I2CEN 100,1000
20 I2CSEND 32,0,1,128
30 Print MM.I2C

when I run this I get a 0 which means the command worked, but the decimal value of 128 on line 20 should enable all the relays?

The C code on the freetronics site for the Arduino version is a little more elaborate?
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 12:20am 30 Sep 2013
Copy link to clipboard 
Print this post

That value of 128 in line 20 will only enable relay 8. If you want all on you have to add the values for each relay. You need a value of 255 for all relays.
 
zcontrol
Newbie

Joined: 14/09/2013
Location: Australia
Posts: 7
Posted: 01:54am 30 Sep 2013
Copy link to clipboard 
Print this post

  BobD said   That value of 128 in line 20 will only enable relay 8. If you want all on you have to add the values for each relay. You need a value of 255 for all relays.


I did try 255 no go. irrespective of the value I add, non of the relay LED are lighting up. I even checked the physical voltage and nothing, so the board although it is ackowledging the command, its actually not doing anything with it.
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 09:01am 30 Sep 2013
Copy link to clipboard 
Print this post

Is there a circuit diagram for the shield ?
I suspect that the LEDs are driven by the same power supply as the relays.
So if the relays are not powered well you know the rest

John

 
zcontrol
Newbie

Joined: 14/09/2013
Location: Australia
Posts: 7
Posted: 11:58am 30 Sep 2013
Copy link to clipboard 
Print this post

  jman said   Is there a circuit diagram for the shield ?
I suspect that the LEDs are driven by the same power supply as the relays.
So if the relays are not powered well you know the rest

John



Hi John, refer to the link above in the first post for a diagram.

But please note that the shield defenitely has power, as the power LED is on, which means that it is ready to deliver power to the relays, assuming the board is instructed to do so!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 07:17pm 30 Sep 2013
Copy link to clipboard 
Print this post

The board has two power leds.
Green for VCC which supplies the relays and the relay LEDs
Blue for 5V supply.
I don't see any 5V regulator so you need 5 to 24V for VCC
and 5V regulated for the IC

Both Green and Blue LEDs need to be on for a working board.

Jim
VK7JH
MMedit   MMBasic Help
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 09:22pm 30 Sep 2013
Copy link to clipboard 
Print this post

Yip I agree with Jim

Stick 12VDC on connector JP6 and I am sure the LED's will spring to life :)

John Edited by jman 2013-10-02
 
zcontrol
Newbie

Joined: 14/09/2013
Location: Australia
Posts: 7
Posted: 10:09pm 30 Sep 2013
Copy link to clipboard 
Print this post

  TassyJim said   The board has two power leds.
Green for VCC which supplies the relays and the relay LEDs
Blue for 5V supply.
I don't see any 5V regulator so you need 5 to 24V for VCC
and 5V regulated for the IC

Both Green and Blue LEDs need to be on for a working board.

Jim


Jim and John, I can confirm that both the green and blue LED are lit and in fact I am getting an I2C return code of 0 from the above program which means I can successfully talk to the board, it just does not seem to actually switch the respective relays on.

At this stage I have to believe this is a software issue although I have not completely ruled out the hardware.

So to summarise:

1. Both LEDs are lit
2. I can successfully send I2C commands to the board
3. Board does not react as expected by switching on the respective relay

I can only assume that I am not sening through the correct I2C command or command sequence.

It would be great if someone could take a look at the Arduino code posted in the link above and come to some sort of conclusions regarding the commands that need to be sent via the I2C interface.
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 10:33pm 30 Sep 2013
Copy link to clipboard 
Print this post

Ok lets try this

Run the code below

Start:

I2CEN 100,100 ' Enable I2C
I2CAddr = &H20 ' this is the 23017 I2C address
' A2=A1=A0=0 <-> x100 000x

Init23017:

I2CSEND i2caddr, 0, 2, &H0A, &B10100000
I2CSEND i2caddr, 0, 2, &H0B, &B10100000

I2CSEND i2caddr, 0, 2, &H05, &B10100000
I2CSEND i2caddr, 0, 2, &H00, &B00111111
I2CSEND i2caddr, 0, 2, &H06, &B00111111

I2CSEND i2caddr, 0, 2, &H10, &B00000000
I2CSEND i2caddr, 0, 2, &H19, &B00000000

' End of Init

I2CSEND i2acaddr, 0 ,2, &H09, &HFF
Pause 500
I2CSEND i2acaddr, 0 ,2, &H09, &H00

End

Post the results

Regards
John
 
zcontrol
Newbie

Joined: 14/09/2013
Location: Australia
Posts: 7
Posted: 04:22am 01 Oct 2013
Copy link to clipboard 
Print this post

John, my friend you are a genious.

The code posted above enabled the LEDs for relays 7 and 8 briefly and then switched them off again.

to be honest I was assuming that this line

I2CSEND i2acaddr, 0 ,2, &H09, &HFF

would enable all the relays, but then again I had no clue to begin with!

Was the result what you expected?

The good news is, you have figured out how to get the board to do something!
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 07:58pm 01 Oct 2013
Copy link to clipboard 
Print this post

Hi
Glad to hear you had some success

Try this code

I2CEN 100,100 ' Enable I2C
I2CAddr = &H20 ' this is the 23017 I2C address
' A2=A1=A0=0 <-> x100 000x
Init23017:

I2CSEND i2caddr, 0, 2, &H0A, &B10100000 ' Control Register Setup
I2CSEND i2caddr, 0, 2, &H0B, &B10100000 ' Control Register Setup
I2CSEND i2caddr, 0, 2, &H05, &B10100000 ' IOCON

I2CSEND i2caddr, 0, 2, &H00, &B00000000 ' IODIRA
I2CSEND i2caddr, 0, 2, &H09, &B00000000 ' GPIOA
I2CSEND i2caddr, 0, 2, &H10, &B00000000 ' IODIRB
I2CSEND i2caddr, 0, 2, &H19, &B00000000 ' GPIOB

Print MM.I2C

Start:

I2CSEND i2caddr, 0, 2, &H0A, &B10101010

Pause 1500
I2CSEND i2caddr, 0, 2, &H0A, &B01010101

Pause 1500
I2CSEND i2caddr, 0, 2, &H0A, &B00000000

GoTo Start


Led's should alternate 10101010 / 01010101

I have attached a link to the 23017 datasheet for you to take a look at

MCP23017 Datasheet

Regards
John
 
zcontrol
Newbie

Joined: 14/09/2013
Location: Australia
Posts: 7
Posted: 10:24pm 01 Oct 2013
Copy link to clipboard 
Print this post

OK that did it, thanks John, I can start doing some useful stuff now! And thanks for the datasheet reference, I was wondering how you got to be so knowledgeable :) In my case without your guidance no amount of datasheets would have helped, hehehe.

Thanks Again.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024