tbd.pi
Posts: 34
Joined: Sat Aug 11, 2012 11:21 am
Location: NJ,USA
Contact: Website

Controlling multiple things at once

Sun Oct 26, 2014 12:33 pm

I have LEDs lighting up, I can use RPi.GPIO to fade them etc. I can control servos, I've used the example that I was given from Joan and I finally got the board working from adafruit so I have options and I just got an adafruit Audio FX sound module that is working nicely.

However, I just tried to put servos and lights together, and I had servos twitching (instead of moving in nice ranged movements) and lights flashing (instead of fading in/out). I'll assume because they were fighting for resources (no threading just yet). I'm using the adafruit library for controlling the servos for now (fewer connections to the raspberry pi), and the RPi.GPIO library for controlling the LEDs.

I tried to thread the lights, no difference although threading is something I rarely ever use in my professional development, python is a whole new game, so I wouldn't be shocked if I screwed that up somehow.

Ultimately, sensors will play into this and I'll want to trigger things, but for now if I could just get servos to move and lights to glow that would be great. I'm not looking for the code, maybe I just need to go and learn a bit more about threading and resource sharing. Any thoughts?

User avatar
joan
Posts: 14266
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Controlling multiple things at once

Sun Oct 26, 2014 12:43 pm

It would possibly be best to focus on why you appear to be getting mutual interference.

Would it be possible for you to post a minimal pigpio program and a minimal RPi.GPIO program which show the problem?

tbd.pi
Posts: 34
Joined: Sat Aug 11, 2012 11:21 am
Location: NJ,USA
Contact: Website

Re: Controlling multiple things at once

Mon Oct 27, 2014 3:30 pm

Thanks as always for the reply Joan.

I broke this out a little more and tested each piece individually. LEDs, I had screwed up the numbers a little, the servo code worked fine. Originally I had started the LEDS flashing and left the servos alone on the main loop, so I went back to the threading and started two threads. I think I have this part working now. The lights flash and the servos move at the same time. Now to add sound.

I'm trying to get up to speed with python and have approximately 3 days left to get it done, so I'm probably rushing a little bit too much here.

Return to “Automation, sensing and robotics”