Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I managed to get the led working on a Raspberry Pi 4. #158

Closed
melaurean opened this issue Mar 3, 2020 · 9 comments
Closed

I managed to get the led working on a Raspberry Pi 4. #158

melaurean opened this issue Mar 3, 2020 · 9 comments

Comments

@melaurean
Copy link

I managed to get the led working on a Raspberry Pi 4.
The led does not initialise with the imported node_rpi_ws281x-native module. It does not report any errors, it just hangs when trying to initialising the led control.
This issue is also described here.

I managed to resolve the issue for now by replacing the imported rpi_ws281x library (of a specific tree version) in the source folder of node-rpi-ws281x-native by the master branch.

Here are the commands when running node-red:

# cd ~/.node-red/nodes/node-red-contrib-tjbot/node_modules/rpi-ws281x-native/src
# rm -rf rpi_ws281x/
# git clone --recursive https://github.com/beyondscreen/rpi_ws281x.git
# cd ~/.node-red/nodes/node-red-contrib-tjbot/node_modules/rpi-ws281x-native
# node-gyp rebuild

So tjbot is now fully operational on a Raspberry Pi 4, at least mine tjbot is.

Originally posted by @chunyianliew in #149 (comment)

@melaurean
Copy link
Author

I just started TJbot High School project using Pi 4 and ran into the LED issue described by @chunyianliew. I applied the commands above to my node v10.15.2 environment with no success. The node-gyp returned OK, but the stty.js (../recipes/speech-to-text) blocks when ran with sudo privileges.
The H/W tests are looking for a 'readline-sync' module which I could not locate, so I could not run test.led.js. Any help would be highly appreciated. I can't revert back to Pi 3 since the school already has Pi 4.

@jweisz
Copy link
Collaborator

jweisz commented Mar 3, 2020

If readline-sync is missing, you may need to do an npm install?

@melaurean
Copy link
Author

Thank you, we'll do!. Any thoughts on the first issue? Failure occurs while TJBot is initializing LED. I attempted many recommended fixes short of changing DMA settings.

@chunyianliew
Copy link

chunyianliew commented Mar 3, 2020

@melaurean, I am organising similar workshops at work for kids of colleagues, so I can share some of my own findings I ran into myself with the Led, assuming that the node-gyp rebuild didn't throw any errors:

  • Please pay attention to the data sheet of the leds, if you have sourced the Neopixel 8mm led from Adafruit, this should be fine. But when you source cheaper alternatives (because I need quite a lot of them, 8 leds per workshop), you might run into issues if you follow the provided connection schema. I myself got 8mm Leds with a WS2811 chipset. But the pin layout of the leds I received are different compared to the Neopixel from Adafruit.
  • I am not certain why you are mentioning DMA settings, but one issue I ran into is that I tried to adjust the code base of the project to allow me to control the led light without root privileges. But that seems not to be possible for the time being. A colleague of mine, @ebaauw, he digged into this issue and explained the following to me: "the led controller expects a datastream of 8-bit RGB values based on a 800 kHz clock signal. A regular computer can not sent a stable clock signal due to CPU interrupts, so a real time system is required for the timing. For the Pi, they have used a brilliant hack: they use the DMA controller to send the data stream from memory to the GPIO pin. However, this hack makes use of the same DMA channel as the on-board audio, hence the need to use a USB or Bluetooth Speaker. That's also why you will see the led starts to blink when you use the on-board audio (speak command)." You need root privileges to make use of the DMA controller.

@melaurean
Copy link
Author

@chunyianliew, many thanks for sharing your findings. I tried both NeoPixel and DIGI_KEY LEDs and so far with little success. All works fine on Pi 3, but not yet on Pi 4. Since the failure occurs in the LED init code I researched that aspect and found a few posts mentioning the need to change DMA channel on Pi4 to 10. I started reading the code but did not jump into making the change yet...

@chunyianliew
Copy link

chunyianliew commented Mar 3, 2020

@melaurean, another option is to try out the following suggestion from @jweisz: #153 (comment)

If you have some patience: I am planning to create a new golden master SD card image for the Raspberry Pi 4 within the coming 2 weeks. I use this image to clone multiple SD cards in one go for the workshops. I can share the instructions to create one yourself together with the actual image with you when I am ready. The workshop is fully focused on usage of Node-Red with the tjbot though.

@melaurean
Copy link
Author

@jweisz Is there a list of S/W component versions that I should observe for TJ? For example the documentation recommends back versions of node.js (6 & 9).

@melaurean
Copy link
Author

melaurean commented Mar 6, 2020 via email

@jweisz
Copy link
Collaborator

jweisz commented Nov 13, 2020

Closing this issue as the tjbot 2.0.0 release adds instructions for getting neopixel LEDs working on RPi 4 in the new TROUBLESHOOTING.md guide, as well as support for common anode LEDs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants