Use GPIO pins to trigger scenes

All the topics related to QLC+ on the Raspberry Pi
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

Hi Massimo,

the beauty in the HAT is that the mechanics is standardized. The screw holes match exactly and there are cut-outs for the camera flat cable and also the DSI display flat cable.

Stacking is very interesting. The HAT has no pins at all. The connector is a flat one with holes only. If you want a stackable HAT you put in a 40-pin female socket with 10mm pins upside down on Raspberry Pi. When you assemble the HAT the pins go through the HAT connector and you have all the pins available for the next HAT module.

You can use either 40 pin or 26 pin connectors. So all HAT modules are automatically compatible with both Raspberry Pi type boards.

You will get the first prototype for free as soon as I have it :)

What I really love in this design is that it fits my theatre perfectly. With 8 push buttons I get everything I need.

- doorbell
- phone
- indoor scene light switch on/off
- all lights on / screen lights only
- window sun simulation day/night
- music 1 introduction
- music 2 intermission
- music 3 end of show

I did notice your question for testing OSX. Looking for a Mac nearby to get it done.

--
regards,
Karri

PS. The design is done with the free KiCad software that is maintained by CERN. This HAT is supposed to be part of QLC+ so that people can use and improve on it. Should the design files go into the GitHub or just be uploaded somewhere? All the component libraries, design and project files are human readable ASCII.

project file:

Code: Select all

update=pe 16. lokakuuta 2015 22.12.52
version=1
last_client=eeschema
[pcbnew]
version=1
LastNetListRead=
UseCmpFile=1
PadDrill=0.600000000000
PadDrillOvalY=0.600000000000
PadSizeH=1.500000000000
PadSizeV=1.500000000000
PcbTextSizeV=1.500000000000
PcbTextSizeH=1.500000000000
PcbTextThickness=0.300000000000
ModuleTextSizeV=1.000000000000
Schematics:

Code: Select all

Title "Isolated GPIO inputs board"
Date "17 oct 2015"
Rev "1"
Comp "QLC+"
Comment1 "by Karri Kaksonen 2015"
Comment2 "this design is Open Sourced. You are free to use this in part of your own projects"
Comment3 ""
Comment4 ""
$EndDescr
$Comp
L CONN_20X2 P1
U 1 1 55717DFC
P 10050 4800
F 0 "P1" H 10050 5850 60  0000 C CNN
F 1 "CONN_20X2" V 10050 4800 50  0000 C CNN
F 2 "" H 10050 4800 60  0000 C CNN
PCB layout:

Code: Select all

(kicad_pcb (version 3) (host pcbnew "(2013-jul-07)-stable")

  (general
    (links 152)
    (no_connects 0)
    (area 107.361686 78.29084 175.140055 158.109355)
    (thickness 1.6)
    (drawings 35)
    (tracks 658)
    (zones 0)
    (modules 55)
    (nets 41)
  )

  (page A3)
  (layers
    (15 F.Cu signal)
    (0 B.Cu signal)
    (16 B.Adhes user)
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

I am still waiting for the PCBs to arrive. They should come on Monday. Meanwhile I invested 31€ in a web site + domain and started to write the documentation in there. I know that the site is still science fiction as the board does not even exist yet.

In any case I will make 10 units. One for Massimo and two for me. The rest are still up for sale.

There is still lots of tests to be done for the Device Tree activation, GPIO pins plugin, DMX output, SPI led output. So the project will not be advertised before the boards are soldered and tested to work.

If you want to have a look at DiscoHAT just click on http://discohat.com

There is one question about the orientation of the DMX cable.

The current plan is to let it stick up straight from the board like here:

Image

The connector plus cable take a lot of space. The alternative is to deliver the DMX connector unsoldered. Then the user could solder a 3 pin cable to the board and mount the DMX socket on the cabinet. Perhaps I make this an option.

Please don't pay attention to the price on the shop tab. It is just a placeholder and that is why I put it so high that nobody would order it ;)

Until it is available of course. Then the real price is calculated from the cost of the chips.

I wrote everything on the web site last Sunday. When I get the real boards I will add photos.
User avatar
mcallegari
Posts: 4462
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

Wow Karri, you're doing such an amazing job on that board !

Due to my limited electronics knowledge, I find difficult to imagine how the connectors will be placed, but I've got a few questions:
1- you mentioned a DMX connector. I suppose it is for DMX output right ? And I suppose it will work with the UART plugin, right ? (have you already tested it ?)

2- how does the SPI connector look like ? In my limited SPI experience I found that it would be very useful to have a connector with screws. Something like this.

3- as far as I understand you are planning to "export" GPIO PINs via RJ45 connectors ?
That means you need to have another custom PCB on the other end to bring GPIO signals into push buttons.
I mean, without a hat, you just need 2 wires and a breadboard to control a GPIO. A total electronics noob like me would go for the easiest solution.
The most common usage of GPIO is a footpedal, where you need 8 strong push buttons.
Maybe an optional connector with screws would be nice here too, so one can easily carry GPIOs around with just a generic multi-wire cable.

4- you mentioned the device tree. Why ? Isn't the one provided by my image (so by Raspbian) generic enough ?

This for now :)
I LOVE the TARDIS and sonic screwdriver thing ! hehe, it seems I'm not the only Whovian here then ;)
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

Hi Massimo,

thanks for the positive comment.

I got the boards and chips. Unfortunately the footprints of the chips did not match the board. So I will make only one for testing it electrically. So there is again a few weeks delay on this project. Drawing the corrected version and ordering PCB's. It is quite cheap as I don't need new chips.

So to the answers.

1) DMX out connector will work with the UART output. Not tested yet but I will test it now before making the next version of the board.

2) Your idea of the SPI connector is nice. I will use that.

3) The GPIO pins are exported via an Ethernet cable because of two things:
- easy to find locally in any lengths
- uses little space

When you cut the end of the cable you find 4 twisted pairs of wire. One pair is then soldered to one switch. So for my demo project I need just a 1m cable cut in the middle to get 2 cables for the switches.

If you want you can also buy RJ45 wall sockets for your switches. Then you do not need to cut the cable but can create a very modular switch system.

4) The Device Tree is mandatory for all products you want to call a HAT. It populates the SPI driver at bootup if it does not exists. It can also set the used GPIO pins to inputs and turn off the pull-ups already at boot time. In reality this is nonsense as we need to do all this for the early Raspberry Pi versions anyway. But if it makes the Raspberry Pi core developers happy why not do it. The big idea is to allow you to stack hats. When you have a HAT module you can see in the /proc/device-tree/hat/. Another thing is that the device-tree GPIO pins can also be used for power-on/power-off functionality and there is even some support for interrupt capability for the pins. I don't know all details yet. Time to do some studying.

The TARDIS turned out really great. I have to post some pictures on my web site. The laminated surface of the design is just perfect. I still need to design some cool smooth lighting for it as it is mostly operated in the dark.
boxy
Posts: 306
Joined: Tue Apr 21, 2015 8:18 am
Real Name: Robert Box

What's the matter with the ICs? have you got wide SO instead of narrow or TSSOP packages by mistake? Shouldn't be a show stopper.
boxy
Posts: 306
Joined: Tue Apr 21, 2015 8:18 am
Real Name: Robert Box

A version of the opto in SO16 package is the SFH6916 from Vishay. This is just of £2 each though from Farnell in the UK.


http://www.vishay.com/optocouplers/list/product-83687/
User avatar
mcallegari
Posts: 4462
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

karrika wrote:3) The GPIO pins are exported via an Ethernet cable because of two things:
- easy to find locally in any lengths
- uses little space
Yep, I totally get the idea and the convenience of using RJ45 plugs and cables but my point was regarding usability.

Once the hat is mounted, you cannot access the Pi IO connector anymore (unless you planned to use a bypass connector as we discussed before) so the only way to use GPIOs is via RJ45.
My question was: will you provide also schematics to build a GPIO "daughter board" where one can easily solder a RJ45 connector and access GPIOs in a wider place ?
I am still thinking about a footpedal, where pedals must be quite big and quite strong.

Another side question: is there a limitation to the length of GPIO wires ? If you provide RJ45, then people will surely buy 50 meters cables and expect them to work ! Obviously I will be the first one to tell them they're dumb. ;)
boxy
Posts: 306
Joined: Tue Apr 21, 2015 8:18 am
Real Name: Robert Box

50m shouldn't be a problem. It's twisted pair cable and if a screen is used it'll be very tough. Earth loops could be an issue with screened cable so it is important not to ground it at the far end, same as DMX.

A related question would be: Are these inputs debounced to prevent spurious triggering? I would suggest 3 samples of the input in a row every 1-5ms or so to confirm a change in state. I expect the GIO inputs are polled regularly?
User avatar
mcallegari
Posts: 4462
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

boxy wrote:A related question would be: Are these inputs debounced to prevent spurious triggering? I would suggest 3 samples of the input in a row every 1-5ms or so to confirm a change in state. I expect the GIO inputs are polled regularly?
Yes, polled every 50ms. At the moment the GPIO plugin works on status change detection, so spurious signals can be a problem.
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

The schematics will be publicly available as well as the KiCad production files. The wire can be long. I will at least test it with 30 m and 60m. There is a series resistor around 920 ohm and a parallel capacitor 10nF that should take care of key bounces and spurious effects by killing resonance. The cable itself has a typical resistance of 0.188 Ohm/m. The voltage 5V comes from an isolated power supply and goes to the opto and the switch. I plan to run around 4mA to the switch. The voltage drop of the opto is 1.2V leaving 3.8V for the cable.

Also the DMX is isolated in this design so there are no earth loops making the system much more robust. There is no screen ground option on the DiscoHAT RJ45 cables.

The opto can only take 6V reverse spikes without breaking so I also add a bypass reverse diode to protect the opto.

Because we definitely do not want any spurious signal to trigger a scene I would love to build hysteresis into the input code. Perhaps you have to read the switch N times and get the same result before you trigger the scene. For me it is very important that my sentimental scene does not suddenly turn into a full light scene with Can-can music because of a glitch on the wire.

The Raspberry Pi also has a new GPIO interrupt class that could be used. I don't know enough of it yet.

Now is a good time to come with advice. I will be testing the design with the crappy boards I have and then I plan to make the bright and shining perfect DiscoHAT :)

Actually I do not need it before our next play in May, 2016 as we will mainly be working on the new play for a few months now.

Here is a picture of my wiring setup.

Image
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

I was a bit unhappy with the mechanics and re-designed the board. The big chips are optocouplers. They don't make them small due to the need for isolating high voltage sparks.

Image

The schematics is on the discohat.com site.
Last edited by karrika on Fri Nov 13, 2015 8:27 pm, edited 3 times in total.
User avatar
mcallegari
Posts: 4462
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

Looks really nice ! Thanks Kicad :)

Looking forward to test the first samples ;)
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

Today I finally had a moment to try out the board.

1. I had to change the GPIO pins a bit around to get them all recognized. No problem.
2. After reboot the GPIO pins were not working. The data was saved properly. In order to get them to work again I had to go to inputs, change pin 14 from "not used" to "input". After this all the pins were working again.
3. The DMX output did not work. I got the message that setting custom speed on port ttyAMA0 is deprecated. I will get an oscilloscope tomorrow to see if the baud rates are correct.

Tonight I plan to build a few protos. You have to accept a few wires as I did some mistakes in the design. But I will fix them for the 1st production run.
User avatar
mcallegari
Posts: 4462
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

karrika wrote:2. After reboot the GPIO pins were not working. The data was saved properly. In order to get them to work again I had to go to inputs, change pin 14 from "not used" to "input". After this all the pins were working again.
I think you need to use a workspace so the GPIO configuration will be saved in it.
Please try and let me know if it works as it should. Otherwise there's an issue and I'll fix it.
karrika wrote:3. The DMX output did not work. I got the message that setting custom speed on port ttyAMA0 is deprecated. I will get an oscilloscope tomorrow to see if the baud rates are correct.
Uhm..this is weird. I fought quite a while against that error (which is kernel dependent) but in the end I resolved it with this block of code:
https://github.com/mcallegari/qlcplus/b ... t.cpp#L111

Are you using my image or did you build QLC+ yourself ?
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

The workspace contained low pins set for input "2,3,4,5,6,7,8,9,10". This may have been traces from some old experiment. Removing these definitions from autostart.qxw fixed the problem.

I am using your image. Perhaps I should start to build this myself also so that I could better help in finding bugs.

I also tried to enter the desired baud rate in /boot/config.txt but it did not help.

At startup I get two messages from QLC
uart-pl011 3f201000.uart: no DMA platform data
uart-pl011 3f201000.uart: UARTWidget sets custom speed on ttyAMA0. This is deprecated.
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

I just had my DMX polarity wrong. The baud rate was ok despite the error message. I am still doing small changes to DiscoHAT. But it will soon be ok.

Merry Xmas

Edit: I have now tried Massimos latest image with DiscoHAT. To me great delight both the push buttons and the DMX output works. I set the baud rate in /boot/config.txt. Actually the output works much better than the USB dongle DMX variants I have. The USB dongles sometimes have a very small glitch (black) between the scenes. The UART based DMX output has no anomalies so far.

The GPIO pins also work direct after boot.

I still need to test the LED strips.

For the final version I will add switching diodes to protect lock-ups to GPIO pins for the SPI pins also.
User avatar
mcallegari
Posts: 4462
Joined: Sun Apr 12, 2015 9:09 am
Location: Italy
Real Name: Massimo Callegari
Contact:

karrika wrote:Merry Xmas
Merry Christmas to you ! :)
karrika wrote:Edit: I have now tried Massimos latest image with DiscoHAT. To me great delight both the push buttons and the DMX output works.

That's great news !
karrika wrote:I set the baud rate in /boot/config.txt.
Uhm...why ?
Is 'init_uart_clock=16000000' wrong ? That's what made the BitWizard hat to work out of the box, and we're still talking about a final baud rate of 250000bps.
What value did you have to set ?
MIght be interesting for me to understand exactly how that parameter works. I guess it's the clock speed in hertz, and I suppose the Linux kernel can scale it down to the requested bitrate in its internal scheduler.
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

I finally got all parts to my DiscoHATs.

Massimo, could you send me your snail-mail address for receiving a HAT :D
rafksy
Posts: 2
Joined: Mon Feb 01, 2016 10:45 pm
Real Name: Adam_

Hi Karrika. Great looking board!.

This may be a little late, I've noticed from the output XLR you have drawn is 3pole. If there are any further resisions to be made to the board it would be better to have a 5 pole XLR fitted as this would conform to the ESTA E1.11-2008

http://tsp.esta.org/tsp/documents/docs/ ... 8R2013.pdf

$0.02
User avatar
karrika
Posts: 60
Joined: Tue May 12, 2015 6:50 am
Real Name: Karri Kaksonen

Thank you for the compliment.

All equipment I have access to use 3-pin DMX connectors. Perhaps the standard does not reflect what is being produced?

Besides, a DMX 3 to DMX 5 adapter at Thomann cost €3.55.

Is there any advantage of a 5 pin connector? Or does it just have 2 extra empty pins?
Post Reply