We are using Matlab to control our raspberry pi 3 using the raspberry pi package.
we use this following code to rotate a stepper motor 100 steps:
clear all; close all; clc;
rpi1 = raspi;
cam1 = cameraboard(rpi1,'Resolution','1280x720');
pul_x = 5;
dir_x = 6;
ena_x = 12;
configurePin(rpi1,pul_x,'DigitalOutput');
configurePin(rpi1,dir_x,'DigitalOutput');
configurePin(rpi1,ena_x,'DigitalOutput');
writeDigitalPin(rpi1,pul_x,0);
writeDigitalPin(rpi1,dir_x,1);
writeDigitalPin(rpi1,ena_x,0);
for i = 1:100
tic
writeDigitalPin(rpi1,pul_x,1);
pause(0.00005);
writeDigitalPin(rpi1,pul_x,0);
pause(0.00005);
toc
end
Our computer connected to the network with lan cable, and the raspberry pi connect to the same network with lan cable aswell.
most of the time when we run this code the whole for loop takes around 40msec average, and there are sometimes that it takes around 8msec average but we are not sure why.
we think maybe it's because the network communication, and maybe there is other way to connect the computer and the raspberry pi to make the runtime faster but we are not sure how to do this.
We would like to get some advices about how to connect them directly, or if there are other suggestions we'll be glad to hear it.
Thanks in advance.
In the hardware setup screen for MATLAB Supportpackage for Raspberry Pi, you can select the option "Connect directly to host computer".
Refer this image.
This will create a direct connection between Pi and your PC. Once this is done, you will be able to access the Pi using the IP 169.254.0.2 (Only from your PC)
Related
I use this library over SPI to control some RGB Leds.
When using the Raspberry Pi 3, I have to set cpu_freq=250 on /boot/config, as far as I've understood, it has something to do with the bluetooth device running on the default serial port.
Now, using the Raspberry Pi Zero W I'm algo having to set that flag.
My questions is, what is the correct cpu clock for both Pi 3 and Zero W, and am I slowing my Pi performance by setting this flag?
i have a raspberry pi connected with two ds18b20 temperature sensor.
-sensor1 is fixed on the outside of my garage (distance 20m from raspberry pi)
-sensor2 is just connected in a breadboard near the raspberry pi.
Everything is working well.
I decided to add sensor3 located outside and from 20m from the raspberry pi.
Now when i type :
cd /sys/bus/w1/devices
if find this:
c0-40a000061005 c2-246056869800 c2-247056869000 d0-008000001000 w1_bus_master1
instead of :
28-.....
28-.....
28-.....
each sensor ref should be start with 28-.....
what is happening with my sensors?
If unplugged the sensor1, then everything is well
if i unplug the sensor3 and let only sensor1 and sensor2 everything is well.
Which modification do we have to do when sensor are located far from the raspberry pi?
thank you
That means that the 3rd sensor doesn't have a 4.7kOhm or 10kOhm resistor between VCC and the OUT wire (black/red one if you have 4wire DS18B20).
Just connect that resistor and it will work , I had the same problem . I spent weeks to find such an easy solution. And if you get the same code after you connected the resistor , that means you didn't connected it properly.Hope will help you
I am sending accelerometer data via bluetooth into Matlab where I will process it and build a GUI.
I am currently working on getting the bluetooth data into Matlab. I'm using a dongle which gets data into port COM18. This is the code I'm using:
s= serial ('COM18');
set(s,'DataBits',8);
set(s,'StopBits',1);
set(s,'BaudRate',9600);
set(s,'Parity','none');
fopen(s);
When I start from scratch (disconnect and connect bluetooth and dongle, reopen matlab etc) The port successfully opens and allows me to read data. However, if I close and then try to open, it will give me an error:
Error using serial/fopen (Line 72)
Open failed: Port COM 18 is not available. Available ports: COM6, COM7, COM19.
use INSTRFIND to determine if other instrument objects are connected
to the requested device.
I know that my device isn't connected to anything else. So I then have to disconnect my bluetooth, dongle, and restart matlab.
Is there a more efficient way to do this?
Also, I am able to get values from my accelerometer into Matlab, but I don't know how to make them continuous. Each time 512 bytes are sent and if my ValuesReceived exceeds 12000, I once again have to restart my bluetooth device to get more values. I've tried flushoutput, but it hasn't worked. Any ideas on how to get continuous data into Matlab so I can process it in my GUI?
I figured out the problem. In order to not get this error anymore I simply had to follow the sequence
fclose(s);
delete(s);
clear s;
and then when I do
s= serial ('COM18');
set(s,'DataBits',8);
set(s,'StopBits',1);
set(s,'BaudRate',9600);
set(s,'Parity','none');
fopen(s);
I am no longer getting the error. It was just the order of operation to close the serial.
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.
I'm new to Raspberry Pi and I don't understand about electricity. I bought a Raspberry B+ today and a 5V 3A power supply, but I'm afraid to connect it because in several places I read about using 5V 2A power supplies. I believe that only higher voltages can damage the Pi but, since I don't know about Amp, I don't know if this is true for 3A too.
My ideia is create a mini-personal server in my home, running Pidora. For data, I have a 1 Tb external USB drive with no external power supply (Seagate model SRD00F1).
My questions are:
can I use the 5V 3A power supply on Raspberry Pi B+ without damage it?
this power supply is compatible with my external USB drive to keep it on safely?
Thank you!
The Raspberry Pi FAQ says that the B+ uses between 0.7 and 1.0 amps, and suggest a 1.2 amp power supply as a minimum.
Using a power supply with a higher amperage rating will not harm your Raspberry Pi. Devices only draw as much current (amperage) as they need. Any additional capacity is unused.
This is where your question about the external hard drive comes in. If you see in the FAQ, they suggest that you might want a larger power supply if you use all of the USB ports. Every USB device you plug in is going to draw more current. To figure out how much you need, you just add up the requirements of all of the devices like so:
Raspberry Pi = 0.7-1.0A
Mouse/Keyboard = 0.5A
Hard Drive = 1.0A
========================
TOTAL = 2.5A
(These numbers are all fake... be sure to check the requirements for your actual devices.)
So if your devices total 2.5A then a 3A supply will handle all of these plus some room for expansion. If all of your devices total 3.5A, maybe you need to consider a bigger one.