Ai Dreams Forum

Robotics => General Robotics Talk => Topic started by: Thierry on November 27, 2017, 10:02:09 pm

Title: How to serial read hundreds of sensors ?
Post by: Thierry on November 27, 2017, 10:02:09 pm
Arduino Uno buffer is limited to 255 characters (may be I am wrong just tell me).
If I want to read hundreds of sensors, how to bypass this ?
Arduino mega is better but I guess not enough ?
Or may be to place a Raspberry with a shield or HAT ?
Or the only way is to add arduinos ?
Title: Re: How to serial read hundreds of sensors ?
Post by: Korrelan on November 27, 2017, 11:24:30 pm
I don’t have any experience with the Arduino but in most language read/ write scenarios the buffer is just the maximum sized block of data that the read/ write functions can handle at once.

So you can fill any size memory array you like but only 255 characters can be passed/ read/ written at once for each function call. 

So 3000 characters is going to be 3000 / 256 =11.7 or a loop that cycles 12 times, calling the read/ write functions.

 :)
Title: Re: How to serial read hundreds of sensors ?
Post by: Thierry on November 27, 2017, 11:35:35 pm
yes I know... Actually I m wondering about the most efficient way to solve this issue...
Title: Re: How to serial read hundreds of sensors ?
Post by: Korrelan on November 27, 2017, 11:57:21 pm
Were are you getting the data stream from? Another computer or an external add-on of some type?
Title: Re: How to serial read hundreds of sensors ?
Post by: keghn on November 28, 2017, 12:12:17 am
 I was thinking about using
a external data bus and a external addressing bus. But a hundred addressing chips, and more, for each sensor
location? That is spread out on a one meter, spinal, addressing and data buss. That can add allot
of weigh,t and get kind of expensive, and bulk for small robot. 

  But i am going with something completely different, that I will be developing over the next few years or  more. And that is to
have a long loop of parallel wires that have a positive and a ground and third sensing wire.
 These wires run in parallel. There will be hundreds of sensors chip on the loop of wires.
 But they will be powered in a very weird way. A sort positive pulse is sent in on the right side and ground pulse is sent in on the left side.
 Where two pulse meat  they will power that sensor for a short time. A third sensor wire, that is connected to all sensor on
the loop, that well be read by the Raspberry. This is a analog read so a analog to digital chip may be needed,
  A Arduino may have one built in?
 For selecting a sensor chips on loop you need carefully timed pulses. which i believe the Raspberry can do with a gigahertz clock and extra
external circuits.




Title: Re: How to serial read hundreds of sensors ?
Post by: Thierry on November 28, 2017, 09:42:11 am
Were are you getting the data stream from? Another computer or an external add-on of some type?

Sensor > arduino > Python (with pyserial module and serialread()) installed on a raspberry.
This is functioning perfectly as long as arduino string is shorter than 255 characters. But what if the string goes more than 255 characters ?
Title: Re: How to serial read hundreds of sensors ?
Post by: Thierry on November 28, 2017, 09:49:08 am
I was thinking about using
a external data bus and a external addressing bus. But a hundred addressing chips, and more, for each sensor
location? That is spread out on a one meter, spinal, addressing and data buss. That can add allot
of weigh,t and get kind of expensive, and bulk for small robot. 

  But i am going with something completely different, that I will be developing over the next few years or  more. And that is to
have a long loop of parallel wires that have a positive and a ground and third sensing wire.
 These wires run in parallel. There will be hundreds of sensors chip on the loop of wires.
 But they will be powered in a very weird way. A sort positive pulse is sent in on the right side and ground pulse is sent in on the left side.
 Where two pulse meat  they will power that sensor for a short time. A third sensor wire, that is connected to all sensor on
the loop, that well be read by the Raspberry. This is a analog read so a analog to digital chip may be needed,
  A Arduino may have one built in?
 For selecting a sensor chips on loop you need carefully timed pulses. which i believe the Raspberry can do with a gigahertz clock and extra
external circuits.

1. I found a way to stack hundreds of servos with a single arduino. This is using I2C. https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/overview

2. Can we do this with sensors too ? I saw a sensor shield but I don't think it has I2C. So I cannot stack ? https://www.sainsmart.com/products/sensor-shield-v5-bluetooth-analog-input
Title: Re: How to serial read hundreds of sensors ?
Post by: ivan.moony on November 28, 2017, 11:35:09 am
Why not reading it in a plain loop? In every step you can change an input range.
Title: Re: How to serial read hundreds of sensors ?
Post by: Thierry on November 28, 2017, 12:22:07 pm
Why not reading it in a plain loop? In every step you can change an input range.

I don't get it. You talk about arduino or python ?
Title: Re: How to serial read hundreds of sensors ?
Post by: ivan.moony on November 28, 2017, 12:23:45 pm
Why not reading it in a plain loop? In every step you can change an input range.

I don't get it. You talk about arduino or python ?
Arduino assembly or Python. Should work both ways.
Title: Re: How to serial read hundreds of sensors ?
Post by: Thierry on November 28, 2017, 12:33:42 pm
Why not reading it in a plain loop? In every step you can change an input range.

I don't get it. You talk about arduino or python ?
Arduino assembly or Python. Should work both ways.

Everything is already in a loop (python and arduino) . What do you mean by "plain loop" and "input range" ? and what difference this would make ?
Title: Re: How to serial read hundreds of sensors ?
Post by: ivan.moony on November 28, 2017, 12:41:13 pm
Why not reading it in a plain loop? In every step you can change an input range.

I don't get it. You talk about arduino or python ?
Arduino assembly or Python. Should work both ways.

Everything is already in a loop (python and arduino) . What do you mean by "plain loop" and "input range" ? and what difference this would make ?

Code
FOR i = 0 TO Sensors.length // loop through any number of sensors
    SET activeSensor = Sensors[i];
    SET data = activeSensor.read();
    doSomething(data);
Title: Re: How to serial read hundreds of sensors ?
Post by: keghn on November 28, 2017, 01:49:43 pm
 If you are going to hook up up a 1000 sensors to a computer you have a choice of 1000 wires to each sensor or one or two
16 bit buss that go to all of them.  This scales quite well.
 Or you can do a analog bus loop. which i am going with and it will scale quite well. But for drones and really small stuff
then a one wire to each device or sensor. And one ground to connect them all. 

But the problem with my way there is nothing on the marked that will do this.


 
Title: Re: How to serial read hundreds of sensors ?
Post by: keghn on November 28, 2017, 02:13:15 pm
System with thousands of Raspberry Pi nodes brings affordable testbed to supercomputing system: 

https://techxplore.com/news/2017-11-thousands-raspberry-pi-nodes-testbed.html

Title: Re: How to serial read hundreds of sensors ?
Post by: Thierry on November 28, 2017, 04:56:20 pm
If you are going to hook up up a 1000 sensors to a computer you have a choice of 1000 wires to each sensor or one or two
16 bit buss that go to all of them.  This scales quite well.
 Or you can do a analog bus loop. which i am going with and it will scale quite well. But for drones and really small stuff
then a one wire to each device or sensor. And one ground to connect them all. 

But the problem with my way there is nothing on the marked that will do this.

Would you connect the bus directly to python ? No need of arduino anymore ?
Title: Re: How to serial read hundreds of sensors ?
Post by: keghn on November 28, 2017, 05:41:12 pm
 The GPIO  pins can read external voltages or output a voltage. These pins are on the out side of the board. Python code can access them:)

Access to GPIO with Python on Your Raspberry Pi 3:   

https://www.arrow.com/en/research-and-events/articles/raspberry-pi-gpio


Title: Re: How to serial read hundreds of sensors ?
Post by: ranch vermin on November 29, 2017, 01:37:18 pm
Like Keghn is saying,   u need a giant parallel buss but u can only do that from scratch cause consumer hardware pretty much always just recurses down a single wire (usb type device) cause its 10000 times easier that way - and having busses thicker than your arm is something youd only see in a tardis somewhere in time. :)
Title: Re: How to serial read hundreds of sensors ?
Post by: Thierry on November 30, 2017, 11:32:04 am
I took some informations.

It seems that multiplexing in my case would bring :
- a huge number of wires going to the same place
- non accurate signals
- a lot of "noise" due to the distance between sensors and processor.

What some guys suggest is to have a master processor receiving data from slave processors themselves connected to sensors (1 slave per sensor).

In this case :
- 4 short wires only between each sensor (A, B, VCC, GRND)
- Technically easier to add new sensors and manage the global architecture

This is the schematic they attached :

http://www.electro-tech-online.com/attachments/rs485-png.49989/

What do you think of this ?
Title: Re: How to serial read hundreds of sensors ?
Post by: Zero on November 30, 2017, 12:58:03 pm
If each sensor emits data at a given frequency (wireless), you can catch'em all at once using Fourier transform. Just use radio waves instead of audio waves!
Quote
An MP3 splits a song into short segments. For each audio segment, Fourier’s trick reduces the audio wave down to its ingredient notes, which are then stored in place of the original wave.
http://nautil.us/blog/the-math-trick-behind-mp3s-jpegs-and-homer-simpsons-face (http://nautil.us/blog/the-math-trick-behind-mp3s-jpegs-and-homer-simpsons-face)

50%  :uglystupid2:
50%  8)
Title: Re: How to serial read hundreds of sensors ?
Post by: Thierry on December 01, 2017, 04:37:51 pm
Hey guys !! I found my Christmas gift !  :D :D :D :D

I don't know what results I will get but at least I must try it ! (yes it is multiplex but I must try to see if it is ok or not)

http://mayhewlabs.com/products/arduino-mux-shield

EDIT : WTF the cost of delivery to France !!!!!!!!!!!!!  :uglystupid2: :tickedoff: it double the price !!!
I will look at China stuff then !
Title: Re: How to serial read hundreds of sensors ?
Post by: keghn on December 01, 2017, 05:48:39 pm
  Another way is to just daisy chained all devices and sensors together. The cpu, or arduino, starts a pulse that activate
the first device. When the device shut down it passes a pulse to the next device int the daisy chain. Odd devices accept
write data, even devices are read data to the cpu. 

Title: Re: How to serial read hundreds of sensors ?
Post by: Korrelan on December 02, 2017, 01:27:02 pm
For one of my projects I used a matrix of 20X20 LED’s that simply changed intensity/ brightness according to sensory stimulus.

I then just pointed a webcam at the matrix and used software to read the values into a program.

I also once used a bank of simple light detecting resistors (LDR) stuck onto a monitor.  So I could control servos etc just by changing the brightness of the section of screen under the LDR's.  That was on a ZX81... so quite a few years ago lol.

Cheap, quick and easy.

 :)
Title: Re: How to serial read hundreds of sensors ?
Post by: keghn on December 23, 2017, 06:09:17 pm
Servo Motor With Raspberry Pi and Maestro board:

https://www.youtube.com/watch?v=mX6P9CwSm7I&t=227s