Author Topic: GPIO Setup  (Read 8964 times)

Offline Materdaddy

  • Moderator
  • *****
  • Join Date: Jul 2013
  • Location: Oceanside, CA
  • Posts: 2,050
  • Kudos: 10
    • Christmas On Quiet Hills
Re: GPIO Setup
« Reply #15 on: November 06, 2015, 12:14:27 PM »
Depending on what you're triggering, what would happen on a reboot?  Whatever is attached to the GPIO will all be triggered until FPPD starts successfully to invert the outputs.  To me, that scenario would be less than desirable and using the uln as ryanjennings suggested would be the best option.  Is your plan to never reboot/update FPP once it is up and running?  What are you attaching to the GPIOs, your lights?

Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,856
  • Kudos: 214
Re: GPIO Setup
« Reply #16 on: November 06, 2015, 01:07:23 PM »
It should be 1 or 2 lines of code to invert the output or multiple solder connections per channel to add a driver chip. This would be a game killer for me!

Where in the code is this output done? Does it happen to be a script which I can modify locally?

It's literally about 15 minutes of code changes to get it configurable via the UI, so I will go ahead and add it for v1.7 which should be out in the next week and a half or so.  I have the code in my head already and just need to get it into git.
-
Chris

Offline oceanwanderlust

  • Newbie
  • *
  • Join Date: Sep 2015
  • Location:
  • Posts: 49
  • Kudos: -1
Re: GPIO Setup
« Reply #17 on: November 06, 2015, 03:07:38 PM »
Please!, thank you!, for adding GPIO invert. I'll continue my build. The relays click rhythmically, so it won't be noticeable that the song is inverted until I decorate.

My setup is:
GPIO-> 8 relays -> 8 power outlets -> simple strand lights

Currently during the boot process, the relays are OFF (this is GOOD) but their LEDs are dim indicating a weak ground. As soon as FPP fully starts, all relays turn on. I figured this latter behavior would easily be correctable with a script or setting in FPP which I haven't had time to find yet.


Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,856
  • Kudos: 214
Re: GPIO Setup
« Reply #18 on: November 06, 2015, 03:19:09 PM »
Please!, thank you!, for adding GPIO invert. I'll continue my build. The relays click rhythmically, so it won't be noticeable that the song is inverted until I decorate.

My setup is:
GPIO-> 8 relays -> 8 power outlets -> simple strand lights

Currently during the boot process, the relays are OFF (this is GOOD) but their LEDs are dim indicating a weak ground. As soon as FPP fully starts, all relays turn on. I figured this latter behavior would easily be correctable with a script or setting in FPP which I haven't had time to find yet.

I found 15 minutes when I should have been eating lunch. :)  I pushed the change to the master branch if you want to test it by switching branches on the developer.php page in the UI.  You will need to delete and re-add your GPIO outputs for the new invert option to show up.

When invert is turned on, the code will drive the GPIO output high when FPP starts and then the line will go low whenever the specified channel is non-zero.

Offline ryanjennings

  • Newbie
  • *
  • Join Date: Dec 2014
  • Location:
  • Posts: 38
  • Kudos: 0
Re: GPIO Setup
« Reply #19 on: November 06, 2015, 06:14:24 PM »
The other thing to watch out for is how much current the pi has to drive the mechanical rekays.  Some will work 8 at a time like you want.  Others draw too much and only a couple will fire simultaneously.

I have used the sain smart 8ch solid state with good results.  It will only switch ac and only 2a per ch. 

Offline oceanwanderlust

  • Newbie
  • *
  • Join Date: Sep 2015
  • Location:
  • Posts: 49
  • Kudos: -1
Re: GPIO Setup
« Reply #20 on: November 10, 2015, 12:52:42 PM »
version control in the UI!? what will they think of next?

Finished my first build of a stand-alone 8 channel FPP over the weekend and CaptainMurdoch's new Invert setting works great!

The Sainsmart knockoff relays only take ~20ma / channel. Also, since I am sinking current (low is ON) instead of sourcing it, it should stress the Pi less.

now, to build another FPP and see if I can get them to synchronize...

thankyou, thankyou!

  joe

Offline bzzbee2

  • Newbie
  • *
  • Join Date: Nov 2015
  • Location:
  • Posts: 5
  • Kudos: 0
Re: GPIO Setup
« Reply #21 on: November 16, 2015, 10:26:46 PM »
The other thing to watch out for is how much current the pi has to drive the mechanical rekays.  Some will work 8 at a time like you want.  Others draw too much and only a couple will fire simultaneously.

I have used the sain smart 8ch solid state with good results.  It will only switch ac and only 2a per ch.

I am working on a setup with the Sainsmart 8ch solid state as you mention above.  I have not finished assembling everything yet, but do i need worry about the invert feature?

Offline oceanwanderlust

  • Newbie
  • *
  • Join Date: Sep 2015
  • Location:
  • Posts: 49
  • Kudos: -1
Re: GPIO Setup
« Reply #22 on: November 27, 2015, 09:50:04 AM »
The invert feature has made it into V1.7 so you just have to press update and wait.


Offline oceanwanderlust

  • Newbie
  • *
  • Join Date: Sep 2015
  • Location:
  • Posts: 49
  • Kudos: -1
Re: GPIO Setup
« Reply #23 on: December 08, 2015, 09:43:13 AM »
NEW GPIO Question, but I thought I'd keep it in the same thread...

What 'fade' level in the sequence triggers a non-fading GPIO output?

Full, 255, makes sense programmatically, but, IMO, blinks the lights too fast when a fading channel is connected to a binary relay. On my old Vixen/Arduino setup, I used 128, aka half. Maybe I'm wrong, but FPP seems to be a bit 'fast'.

Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,856
  • Kudos: 214
Re: GPIO Setup
« Reply #24 on: December 08, 2015, 12:56:09 PM »
NEW GPIO Question, but I thought I'd keep it in the same thread...

What 'fade' level in the sequence triggers a non-fading GPIO output?

Full, 255, makes sense programmatically, but, IMO, blinks the lights too fast when a fading channel is connected to a binary relay. On my old Vixen/Arduino setup, I used 128, aka half. Maybe I'm wrong, but FPP seems to be a bit 'fast'.

FPP's current GPIO support is on/off, so anything non-zero is on and zero is off.  We could possibly make it configurable in a future version.  I also want to find out if having software PWM support would allow people to use dimming with the GPIO output.  WiringPi will let us use PWM on the outputs but I haven't tried hooking up test code or a circuit yet.  If it's not something that could be used by the devices connected then I wouldn't bother.

Offline pbudden

  • Newbie
  • *
  • Join Date: Jan 2016
  • Location: Shanklin, IoW
  • Posts: 10
  • Kudos: 0
Re: GPIO Setup
« Reply #25 on: January 10, 2016, 03:36:00 AM »

FPP's current GPIO support is on/off, so anything non-zero is on and zero is off.  We could possibly make it configurable in a future version.  I also want to find out if having software PWM support would allow people to use dimming with the GPIO output.  WiringPi will let us use PWM on the outputs but I haven't tried hooking up test code or a circuit yet.  If it's not something that could be used by the devices connected then I wouldn't bother.

This answers a question I have been searching for.
I have currently built an arduino dimmer that uses a TLC5940 to dim dumb LED strips with PWM. As there is no easy way to get this interfaced with FPP I looked at the 74HC595 where it connects directly to the Pi and FPP.
Then discovered there is no control over intensity with PWM :(
Granted, most effects are on/off, but some transitions and effects look good with fade in and out.

If you implement SoftPWM on the GPIO you can run relays with a full on/off on that channel if desired, so we would have the best of both worlds.
My TLC setup uses SoftPWM to drive 16 MOSFETS for high power and fast switching.
The TLC has 16 outputs and can be cascaded, and if you ask TI nicely, they will send you some for free ;)

Thanks
PB

Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,856
  • Kudos: 214
Re: GPIO Setup
« Reply #26 on: January 11, 2016, 04:12:55 PM »
I have currently built an arduino dimmer that uses a TLC5940 to dim dumb LED strips with PWM. As there is no easy way to get this interfaced with FPP I looked at the 74HC595 where it connects directly to the Pi and FPP.
Then discovered there is no control over intensity with PWM :(
Granted, most effects are on/off, but some transitions and effects look good with fade in and out.

If you implement SoftPWM on the GPIO you can run relays with a full on/off on that channel if desired, so we would have the best of both worlds.
My TLC setup uses SoftPWM to drive 16 MOSFETS for high power and fast switching.
The TLC has 16 outputs and can be cascaded, and if you ask TI nicely, they will send you some for free ;)

How do you talk to the arduino dimmer currently?  Or are you wanting to connect the TLC5940 right to the Pi?

It looks like this library can control the TLC5940 from the Pi:  https://github.com/sh4wn/tlc5940-raspberry

If you can test his example program on the Pi and it works acceptably without 100% CPU usage, then I am willing to take a shot at adding a TLC5940 Channel Output in FPP.  I read through the notes but am not sure about how frequently the 'update' function needs to be called, so I'm curious how much CPU usage this will require.  FPP would have to scale the 0-255 level input to 0-4097.

powerfix is also looking at using wiringPi's SoftPWM() support to dim on some of the other channel outputs, so there may be another option later.

Offline powerfix

  • Newbie
  • *
  • Join Date: Dec 2015
  • Location:
  • Posts: 14
  • Kudos: 0
Re: GPIO Setup
« Reply #27 on: January 12, 2016, 04:36:38 AM »
I've had a look at both the TLC5940 and PCA9685 and in my opinion, the PCA9685 is the front-runner.

I think the channel output and development should revolve initially around the PCA9685 chip due to the fact that this chip has a built in clock - no need to send pulses and tie up the CPU on the Pi. Again, not an expert and happy to be proven wrong - but the Adafruit guys have summarised it as below (excerpt from https://www.adafruit.com/product/815)

Quote
When we saw this chip, we quickly realized what an excellent add-on this would be. Using only two pins, control 16 free-running PWM outputs! You can even chain up 62 breakouts to control up to 992 PWM outputs (which we would really like to see since it would be glorious)

  • It's an i2c-controlled PWM driver with a built in clock. That means that, unlike the TLC5940 family, you do not need to continuously send it signal tying up your microcontroller, its completely free running!
  • It is 5V compliant, which means you can control it from a 3.3V microcontroller and still safely drive up to 6V outputs (this is good for when you want to control white or blue LEDs with 3.4+ forward voltages)
  • 6 address select pins so you can wire up to 62 of these on a single i2c bus, a total of 992 outputs - that's a lot of servos or LEDs
  • Adjustable frequency PWM up to about 1.6 KHz
  • 12-bit resolution for each output - for servos, that means about 4us resolution at 60Hz update rate
  • Configurable push-pull or open-drain output
  • Output enable pin to quickly disable all the outputs

I'm keen on not tying up the processor at all and being able to run essentially 992 from the one Pi (in theory).

Thoughts?

Offline pbudden

  • Newbie
  • *
  • Join Date: Jan 2016
  • Location: Shanklin, IoW
  • Posts: 10
  • Kudos: 0
Re: GPIO Setup
« Reply #28 on: January 12, 2016, 05:02:48 AM »


How do you talk to the arduino dimmer currently?  Or are you wanting to connect the TLC5940 right to the Pi?


Currently I am communicating to a ATMega328 via RS485 serial driven from my laptop with Vixen3 talking out of a Generic Serial.
Its a gludge to prove it worked.  There are some odd things with the circuit which require a rebuild.
This got me thinking about more reliable methods of comms.
At this time I am unable to locate much in the way of Arduino sketches to receive and decode DMX512 or E1.31 that I can understand.
which would make this a mute point.

It looks like this library can control the TLC5940 from the Pi:  https://github.com/sh4wn/tlc5940-raspberry

If you can test his example program on the Pi and it works acceptably without 100% CPU usage, then I am willing to take a shot at adding a TLC5940 Channel Output in FPP.  I read through the notes but am not sure about how frequently the 'update' function needs to be called, so I'm curious how much CPU usage this will require.  FPP would have to scale the 0-255 level input to 0-4097.

I am most peoples nightmare, I know enough to be dangerous in a lot of things, including programming and hardware.  I can look at the library and if there are examples or clear directions on creating an example/test code I can do it and report back.

As for the update, once the TLC has been updated with the value it maintains the PWM level until the next update.
I don't see why an output with however many channels can't be sent to the GPIO-TLC in sequence as it is presented to that display channel. Sorry if I am over simplifying this.

Speaking of nightmares above, I spoke incorrectly in as much as the TLC has its own PWM and not SoftPWM from the driver like the 74595 would.
(I confused that issue as I have too many plans for this and they all merge together.)
It will require a map from 4095 to 255 as you point out, but that should be a basic function prior to sending to the output. 
map(value, fromLow, fromHigh, toLow, toHigh)

Description

Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, a value of fromHigh to toHigh, values in-between to values in-between, etc.


---

While I was typing this I see powerfix posted.
I was unaware of the PCA9685.
It looks good, but will " free running " introduce timing constraints like WS2811 vs WS2801 ?

The other thing is that a quick search and I am unable to locate PCA9685 in a DIP package.
I have not advance to SMD in my hobby electronics yet.

Swings and roundabouts

PB

Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,856
  • Kudos: 214
Re: GPIO Setup
« Reply #29 on: January 12, 2016, 03:38:12 PM »
I've had a look at both the TLC5940 and PCA9685 and in my opinion, the PCA9685 is the front-runner.

I think the channel output and development should revolve initially around the PCA9685 chip due to the fact that this chip has a built in clock - no need to send pulses and tie up the CPU on the Pi. Again, not an expert and happy to be proven wrong - but the Adafruit guys have summarised it as below (excerpt from https://www.adafruit.com/product/815)

......

I'm keen on not tying up the processor at all and being able to run essentially 992 from the one Pi (in theory).

Thoughts?

I'm fine with either or both, but anything that uses less CPU is definitely preferred.  FPP isn't about just supporting new things, I've also tried to support users with older setups to give them a migration path to newer/better solutions. :)

On the TLC5940, there is one post from "since_z80" in the comments section of the TLC5940 page that describes how to use the Pi's SPI clock to drive the TLC5940 rather than doing it in software.  If that works, it wouldn't tie up the Pi's CPU.

 

Back to top