Author Topic: Raspberry Pi GPIO output direct to SSR board  (Read 11959 times)

Offline powerfix

  • Newbie
  • *
  • Join Date: Dec 2015
  • Location:
  • Posts: 14
  • Kudos: 0
Re: Raspberry Pi GPIO output direct to SSR board
« Reply #30 on: January 07, 2016, 04:08:11 PM »
Yeah, the CPU usage is strange. It seems to fluctuate a little - it could be my setup and loose testing methods too.

The test setup I've got using RPIO.PWM is great - there is basically no flickering at all and nice smooth fading. I've had a look at the back-end of wiringPi specifically for the 2 chips and there are only about half a dozen methods in each, essentially the same just with a different pin config. I think we have a couple of options here.

1. Request wiringPi developer to implement the DMA method of software PWM instead of the clock based PWM that it's currently doing (ideal solution across the board)
2. Request RPIO.PWM developer to implement the MCP chips
3. We undertake option 1/2 ourselves. For our purpose, this would mean a full PWM on any GPIO pin, whether on board OR via expansion boards. Essentially giving a RPi up to 128 channels of PWM on board (assuming that CPU is under control)
4. Ditch the PWM on the FPP RPi GPIO's completely and just use external hardware.

I'd really like to see PWM on the GPIO pins, but I'm not sure my level of ability/knowledge will suffice. Ideally, if we could get the developer of wiringPi on board, I think that would be the best solution.

In relation to the caching, I've only used Memcache/d on PHP - I've done some googling however have found little that makes sense to me for caching through C++. Are you able to point me in the direction of an example?

Cheers.

Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,836
  • Kudos: 214
Re: Raspberry Pi GPIO output direct to SSR board
« Reply #31 on: January 07, 2016, 05:56:55 PM »
The MCP chip requires a i2c call to set the values while I believe the Broadcom CPU supports toggling the GPIO pins by writing to a memory location, that is why DMA works for the onboard pins but I don't think it will work for the MCP connected over the i2c bus.  The SPI version might be faster but that might be limited in the number of outputs it could support.  I will try to do a little research but you might want to search for "raspberry Pi PWM over i2c" to see if anyone else has tried.

For the cache, that is just an array where you track the last known value.  If the last known value is the same as the new incoming value then don't issue the softPwmWrite call to "change" the value.  I haven't looked at the wiringPi code so Gordon may already do this in the library itself.
-
Chris

Offline powerfix

  • Newbie
  • *
  • Join Date: Dec 2015
  • Location:
  • Posts: 14
  • Kudos: 0
Re: Raspberry Pi GPIO output direct to SSR board
« Reply #32 on: January 10, 2016, 05:07:51 AM »
Thanks Chris,

I shot off an email to Gordon, author of wiringPi, and he was very helpful with hist responses.

Essentially, without an expansion board for the Pi specifically for hardware PWM, there are limited opportunities to use software PWM. The DMA method works with onboard pins only, and due to the slow speed of I2C, Gordon is of the opinion that the flickering will continue. And actually get worse with the more pins enabled.

I think I'll enable the MCP chips for on/off only, as it already the case.

Disappointing, but I'll be investigating some additional expansion boards with hardware PWM. There is another chip PCA9685 (https://www.adafruit.com/product/815) that looks to be the way to go, and can add something like 992 channels daisychained.

There are already a couple of ports into wiringPi, so hopefully this will be a little more fruitful.

Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,836
  • Kudos: 214
Re: Raspberry Pi GPIO output direct to SSR board
« Reply #33 on: January 11, 2016, 04:17:45 PM »
I think I'll enable the MCP chips for on/off only, as it already the case.

Disappointing, but I'll be investigating some additional expansion boards with hardware PWM. There is another chip PCA9685 (https://www.adafruit.com/product/815) that looks to be the way to go, and can add something like 992 channels daisychained.

There are already a couple of ports into wiringPi, so hopefully this will be a little more fruitful.

Check out the thread on the TLC5940 as well to see what you think about that and if it would be an option.  I linked to a library I found, but I haven't done anything other than a quick read over the docs.    http://falconchristmas.com/forum/index.php/topic,2961.msg43720.html#msg43720

 

Back to top