raspberry pi gpio or rs232 relay board for simultaneous output bit-map? - raspberry-pi

I really wanted at first an rs232 8-channel relay board that I could command devices to turn on/off with a command string.
All of the ones I found online have the same deficiency in functionality for me: you can't set a subset of relays at the exact time. I can set relay 1 on, and then relay 7 on afterwards, I can set all 8 relays at once, but there is no command structure to pick out the exact leds I would like to turn on/off.
In the past I have dealt with hardware that had a bit-map of the IO pins, and a bit-map of the states and would apply all 8 settings at once. here are some examples:
to set pins 1 and 7 to on and the other pins off (8-bit binary bit-mapping,) send the following byte: in binary: 0100 0001b
to set pins 1,2,3,6 to on and the other pins off (8-bit binary bit-mapping,) send the following byte: in binary: 0010 0111b
I couldn't find any such device to do this so I thought I could make one with a raspberry pi using a simple 8-channel relay board, something like this:
https://www.amazon.com/SainSmart-101-70-102-8-Channel-Relay-Module/dp/B0057OC5WK
but on a Raspberry Pi, I'm running into the same issue: I don't see a way to set the gpio pins as a block command, only individually setting them in a for loop. I looked all morning and can see things like gpioctl, and mmio, but I can't put it all together to a simple proof of concept program on a testboard, any help would be appreciated.
I would really like a solution in C or scripting,
Thanks,
jleslie

Related

Can I directly connect a GPIO OUTPUT and INPUT

Can I directly connect a GPIO OUTPUT and INPUT of a raspberry pi? I heard that this would be dangerous in case that both GPIOs are accidentally set as outputs and that it is better to put a resistor of at least 220 ohm in between (not to ground?). Is this really necesarry?

Raspberry Pi - How to measure 2 resistor values with GPIO

Is it possible to measure 3 specific resistor values by using GPIO / Without using a full ADC setup?
I have an alarm sensor that I want to hook up to my GPIO. This sensor has 3 specific resistors value, based on it's state:
1) Normal - 4k7
2) Alarm - 9k3
3) Tamper - infinite.
Due to long lines, I would prefer 12V power on one side.
I would like to be able to detect these states by 2 normal GPIO input pins.
Is that even possible? What would be the schematic needed for this?
Or is the only solution to use (external) ADC's?
I am thinking about a voltage diver with resistors and a 1N4148 diode to clip it to 3v3. But so far my results are unfruitfull.
Thanks.
The problem here is you have three levels to measure. If we had two we could use a simple resistor divider setup to make (say) the 4k7 and 9k3 outputs on the sensor to logic 0 (<=0.8V) or logic 1 (>=1.3V) on a single GPIO pin. We could do this on two GPIO pins if we had two "independent samples" of the sensor output rather than one.
Given the above it is possible to design some simple logic network to do the comparisons but as the other comment mentions you're off into the realms of electronics.
ADC is the simplest way to go if you want to stay in the software domain. The are other SBC devices e.g. ESP8266 which have onboard ADC functionality and built-in Wifi https://esp8266-projects.org/2015/03/internal-adc-esp8266/ or you can hook up an add-on ADC to the Rpi for example https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters
Good luck

Ethernet cable to DB15 connector

Morning Overflowers,
For a specific in-house application for my company, I need to be able to make a Gigabit ethernet connection go through DB15 connectors, as seen bellow.
Here is what I'm trying to achieve:
For the first version, I just cut in half a cat 5e ethernet cable. I did not care too much about the pin-out from the cable to the DB15 connector and in the end I ended up having a 10MBit/s data rate, which is super low. Also my cable was super short, 2m in total.
For the second version I used a 5m cat 6 cable for one side, and the remain of the other cat 5e cable (resoldered) for the other side. I was more careful about the pinout and used the 4 left most pins to place the ethernet pairs as seen here:
The data rate is this time 100 MBits/s, but still not 1 GBits/s.
Before going through a 3rd version I thought I'd use my brain a little. I noticed while soldering that although inside a cat 5e/cat 6 cable there are 4 pairs, not all of them are side by side on the RJ45 socket as seen on figure bellow where blue and green wires are a bit mixed.
There is probably a reason for that arrangement and putting pairs together other that inside the cable itself is not probably a good idea, which leads to my question.
For version 3, should I just keep pin 1 to 8 in that order and solder them to the DB15 connector on adjacent pins?
More generally I am aware that unless the DB15 section is super short I won't be able to maintain Gibabit ethernet due to noise and other problems caused by unmatched pairs on that section.
I am open to any suggestion or tips or anything :)
Thanks in advance
After trial and errors, it turned out that it works fine if you arrange pairs to match a RJ45 connector (like on the figure "ethernet plug wiring"). The quality of the cable is probably not the one of a perfect 5e/6 cable but my computer can negociate a Gbits connection and transfer files over the network at speeds way above 10 MB/s reaching 50 MB/s. I always soldered more section with various connectors and it worked fine too.

Raspberry Pi - More GPIO pins or/and more leds

Like the title said, I need more GPIO pins or just a way to control a lot leds
So I need to control more than 40 leds, or even more, anyway more than raspberry pi has GPIO pins. So I know that there is extension board for Raspberry Pi that extends the GPIO, that's one way to solve it. If anyone ever had one can recommend it to me.
Another idea that I got was to use led matrix but instead use the same idea, I mean for example led row 1 and column 4 or so, but the leds won't be in Grid, instead, they will be separated with wires. But the problem, if we want to do like that:
X O X
O X O
X O X
where X is on and O is off, it's not possible. All leds will be lit up, not like in the pattern. If anyone has the solution to one of the ideas then please share it with me, thank you for your time!
You want to control lots of LEDs using as few GPIO pins as possible.
Solution
The way to do this is to use a technique called Charlieplexing. The name comes from the inventor, Charlie Allen of the company Maxim, and the technique takes advantage of the feature of GPIO pins that allows them to be changed from outputs to inputs while a program is running. When a pin is changed to be an input, not enough current will flow through it to light an LED or influence other pins connected to the LED that are set as outputs.
use breadboard
for more information go to this link
http://razzpisampler.oreilly.com/ch04.html

Anker Astro E4 to power Raspberry Pi

Looking for some help to be honest, This is not my area of knoladge atall.
Ive read around the question of powering my Pi with a battery, now I nabbed one of these guys for my phone
http://www.amazon.co.uk/13000mAh-Portable-External-Technology-Motorola-Black/dp/B00BQ5KHJW/ref=sr_1_cc_1?s=aps&ie=UTF8&qid=1420826597&sr=1-1-catcorr&keywords=anker+astro+e4
Incase the link dies in the future;
Item model number: AK-79AN13K2-BA
AnkerĀ® 2nd Gen Astro E4 13000mAh 2-Port (3A Output) Fast
Max 3A Out
5V Out
Now, from what i've read there have been mixed notes of, don't use batterys, only use this battery, don't do this, don't exeed this magical number ( which was differant each time ). so any help would be grately needed. If i was to power my pi via this thing. im I going to get a poof of smoke and need to replace the poor pi :(
A raspberry Pi is powered via USB, which means that it simply takes the 5V supplied via USB to run. As long as your current source is stable (ie. it doesn't change when you draw current from it), no device will care whether it is a battery or a switching power supply. Now, a bare raspberry Pi B uses less than 2W of power, 2W/5V = 0.4A = 400mA, so if that battery pack lives up to its specification, you are going to be fine. The device is spec'ed to provide 13000mAh, so at a constant current of 400mA, this would last you more than 32 hours.
Now, most people attach something to the raspberry, and that something will also draw power, but just add that power to the calculations above, to see if it's going to work out.