Week10, Input devices

Week10, Input devices

Input, get to know sensors and how to use them in your projects. Play around with sensors in the group and design and produce a board with which you can measure something.

Wednesday Global Class

Right after the group-project-presentation Neil explained everything about different input-devices. Next to the different devices he showed how to hook them up and measure something with it. and what de different measurements do with the output. Really nice and a lot of information.


Weekly Assignment

In my own words

Group assignment:

  • Play and test different sensors and learn how to read information with the tools available Individual assignments:
  • design and prduce a board with a sensor that you are able to read.

Planning this week

New Corona rules in Amsterdam, we can come every day as long as we test twice a week. We'll have local class on thursday, on friday I have a funeral and on monday and tuesday I have several meetings from work, so I made my planning around this schedule.

Day Lesson subject/activity activities
Wednesday global class make this plan
Thursday local class sensors group assignment play with different sensors
Friday family matters
Saturday Buy the right sensors work on ultrasound global open time
Sunday family-time
Monday Work in KiCad afternoon local Fab time get my board milled Solder in the evening
Tuesday debugging and get everything to work Try out different options with the board Documentation
Wednesday presentations ready to present fix last things

Sensor Local class

Henk explained about the different sensors and how they work, in general they will give a analog value. Therefor you can make a program that will translate the analog value to a measurement of some sort which is readable on the serial port or is used to give some output.


Group assignment

For the group assignment we searched around at the lab for different sensors, which gave us a humidity/temperature sensor several light sensors and a movement sensor. After that we took our good old hello-world boards and measured in all kind of ways what we could. We tried measuring with the oscilloscope, that was quite hard, but after a while we got the hang of it. And we tried the logic analyser, which was good fun and, with being quick and pressing the button on the board it was quite cool to see what that would do to the output.

lightsensors Next step was the serial read, we tried that with different sensors and found some code online for the different set-ups with arduino. First up was the light sensor, since that one is easily changed by using a flashlight or your hand. one of the lightsensors was not sensitive to led-light and so I picked up one of the big magnifierlamps for soldering to check if that was true. And yes, with that lamp we could get it to go up to 1000. so our roles were set for the afternoon.

Nadieh and Loes wanted to try out the Time of flight distance sensor and Henk was digging in his secret drawer and lent it to us. It was really a teameffort to get it working. The connection onto the breadboard was instable and one person had to hol that, I was the famous hand-model and kept my hand at different distances over the board and we could read the distance between the sensor and my hand in the serial output.

Motionsensor PIR We worked the same way with the motion-sensor I moved my hand in the area above the lamp and Loes and Nadieh looked at the data and tried to uinderstand what was happening. For the motionsensor it took quite a while to turn of again.

Microphone After that Nadieh went home, but I wanted to check out something with a microphone, because I am planning to play with that this week. We could not find anything, but when we asked Henk, he opened Henks special cupboard again and gave us a box with a lot of different sensors. Microphone was missing though. but Henk retrieved an extra sensormodule and we could play on. We had to work this one, because it has a potentiometer on the board and it took us a while to find the right setting so it would work. We really had fun, because I had to say PEHP really lopud to make it work. After this we decided to put it back in the box at 'Microphone, (small sound)'


Individual assignments

Design and fabricate a board with an input and measure something.

My plan is to work with ultrasone sound, I have a 'bat-detector'. I soldered it from a set I think 20 years ago and sadly enough it is not working anymore. What my bat-detector used to do is the conversion of the high-pitch-sound that bats use for their Radar to a hearable sound. It is not literally converted, but it sounds either like beeps or like ticking noises.

It is really fun to sit outside at night and listen to the bats that are flying by. And with some practice it is even possible to hear the distinction between the different bat sound and so you can say what kind of bat it is.

Saturday

What I need is a sensor that can detect Bat-noise, I need a 'converter' and I need a speaker to listen to the noise. In which of course the converter is the hard part.

I looked good at my own bat-detector and found that the big capacitor right next to the microphone has one pin loose, also the wires to and from the headphones seem very messy. It is hard to tell how this thing is really build up, not all the numbers are readable. The 'Philips HEF4024BP seems to be a 7 stage binary counter and can be used as a frequency-devider. That is good news, because it will be useful to find a solution for changing the frequency. But on the other hand Philips is now NXF and the datasheet is from 1995. And it seems quite complicated.

On the bottom of the board it is clear that there is a repetative action with the input. That is of course because it is a microphone which has a very little signal and needs to be amlified. these components I can find and label. BUt the hardest part is the big friend near the microphone, it says 103J 00119 on it, but I cannot find anything online that is close to what I have here.

I cannot find anything on the fabacademy-site on building Bat-detection but that is also because a lot of people explain the echo-measurement-system with 'bats' as an example. SO I found a lot of hits, but no useful information

I looked online to find out what I need and what solutions there are. I cannot find something close to what I have at hand, but I do find some good sites with a lot of technical information and self-built-kits.

THis gave me a lot of information on how batdetectors work and the sound that they convert.

On the MAGENTA site they say: 'It is a "heterodyne" circuit which mixes a tuneable oscillator with ultrasound emitted by bats, to produce an audible output. Thus the ultrasound is processed to generate audio signals which the human ear can detect. 20 to 110kHz tuning range. Front facing loudspeaker output.'

And with this information I could make a new bat-detector but it is not in time and to big for this week

TO the shop

At the end of today it is open-time and I can ask everybody there if they have ideas, but I have to visit the electronics-shop before that so I hope they can help me.

Sadly enough they did not have something to make a Bat-detector, or an ultrasonic microphone, what they did have was the ultrasonic echoset that Henk showed us on thursday and the guy at the shop told me that I probably could be able to not use the transmitter and take only the output of the detector. That sounded like something to work with.

At home I looked online and only found the echo-software for the arduino, so first I tried that. arduinolearning and randomnerd It works great.

 1/*
 2VCC to +5V
 3GND to ground
 4TRIG to digital pin 12
 5ECHO to digital pin 13
 6*/
 7 
 8const int TRIG_PIN = 12;
 9const int ECHO_PIN = 13;
10 
11void setup() 
12{
13  // initialize serial communication:
14  Serial.begin(9600);
15  pinMode(TRIG_PIN,OUTPUT);
16  pinMode(ECHO_PIN,INPUT);
17}
18 
19void loop()
20{
21  long duration, distanceCm, distanceIn;
22 
23  digitalWrite(TRIG_PIN, LOW);
24  delayMicroseconds(2);
25  digitalWrite(TRIG_PIN, HIGH);
26  delayMicroseconds(10);
27  digitalWrite(TRIG_PIN, LOW);
28  duration = pulseIn(ECHO_PIN,HIGH);
29 
30  // convert the time into a distance
31  distanceCm = duration / 29.1 / 2 ;
32  distanceIn = duration / 74 / 2;
33 
34  if (distanceCm <= 0)
35  {
36    Serial.println("Out of range");
37  }
38  else 
39  {
40    Serial.print(distanceIn);
41    Serial.print("in: ");
42    Serial.print(distanceCm);
43    Serial.print("cm");
44    Serial.println();
45  }
46  delay(1000);
47}

I measured the distance to the other wall of my room 3,40 meters, the wall behind me is only 1,54 meter away, and it can really measure upclose too, my hand could be measured at 3 cm distance.

sound-output

Then I tried to use the 'out' pin and used it with another example code for converting sound to serial. teachmemicro

 1int soundPin = A0;
 2 
 3void setup()
 4{
 5  Serial.begin(9600);
 6}
 7 
 8void loop()
 9{
10    long sum = 0;
11    for(int i=0; i<100; i++)
12    {
13        sum += analogRead(soundPin);
14    }
15 
16    sum = sum/100;
17 
18    Serial.println(sum);
19 
20    delay(10);
21}

This was really cool: in my plotter I really got some information, you can even see the point where my husband was moving some small things. So it seems quite promising. I have no clue how to make output from this but at least I do have a signal

I really have to dive into the subject of amplifiing audio (although I have never done anything like that) I hope I am able to make something with it and that there are some nice examples to build on.


Saturday open time

This last bit of real-life research was during open-time. So I was really looking forward to getting some help on what to do next. and I was very eager to hear about different options and possibilities. But there were quite some people with questions. Paula for instance asked about how to put a 'gas-detecting-sensor on her board and how to know what components should go with that. The Open-time-friends explained that you don't really have to know because you can easily buy a module with the sensors already made on it with the right components accompanying them. and it is quite useless if you can buy the module easier than the separate parts. This really opened my eyes, I could maybe try to make my board capable of using my new echo-toy.

I asked about Bat-detectors and showed my old one and told about my plans to make a new one I learned that it is not a wide-spread subject within the fabacamy-group because I really had to explain in detail how that would be fun (to hear a bat) but with that information Rico also found a great example at nuts and volts.

They also asked what this has to do with my final project and I said that I thought the analog input of a tempereature-sensor, a humidity-sensor, or a gas-measurement-sensor are basically the same, since they are all analogue values between 0 and 1023 and it would be basically the same for all.

This whole experience gave me a brand new idea for this week. I will try and make a miniature arduino just for different sensors. I want to be able to use the different sensors in my wormbin and meanwhile I can try to figure out if I could make my board capable of using my new echo-toy as well.


Sunday

with my new idea all fresh in my head I had to work out a new plan.

The echo-sensor is complicated because it has 5 pins and I only have three left at the attiny412. Only after researching if it is possible to use the UPDI-pin for an extra input after loading the program I realised that the 5-pins of my echo-board are of course really 3 pins and power and ground. so 'problem solved' I worked on temperature, humidity of the ground and air, gasses for a while, but on sunday the shops are closed (now with corona for sure) so there is no way of triing anything out. I did find that the sensor-kit that Henk has is only 24 euro's at my electronicsshop.

That would be great. I looked at the pictures, but it was impossible to see how the pins were located in the different modules. so I looked online and found that most modules have 3 pins: ground, 5volt and 'out'/'signal' or something like that.

Only downside of my plan is that the electronicsshop is also closed on monday and therefore I can only start and play on tuesday.


Monday Designing.

First some sketches and comoaring the new idea with the HelloEvis board.

I made a schedule with the attiny and the possible configurations Loes came over to my house to work together, since we first have to design the boards and only afterwards can use the milling in Amsterdam. Worked with Loes on getting everything in Kicad, I started with the Attiny412 and made sure that my RX and TX are the right way around (so swapped to the placing on the hello board)

First updi and ftdi Updi with power, the way Adrian made it. Then the female connector for the echo-module with all 5 pins. This will be functional to all modules that need more than one input/output pin.

I checked the datasheet of the attiny412 and found that all 3 free pins are capable of digital and analog input and output. I don’t know if it is crucial but I think it is, so I also placed the capacitor on my board which is connecting the vcc and ground. I decided on 3 seperate 3-way-connections for the sensors. With VCC, ground and input/output pin, that way I can connect three things, for example two inputs and a led, or the other way around 1 input and two outputs.

In the layout design it is very complicated to connect all the lines. While I try to help Loes I find that she is of course using her components as bridges, but I don’t have any components that allow to be bridges already. So I decide to build extra bridges. Adding extra components in the lauout-design only gave me loose components that don’t want to be altered or fit in with the rest. Although I did not expect it, it is quite easy to combine the layout design with some extra components added in the schematic design.

Design rules All of a sudden I thought of the design rules, finding them was quite a hassle, but then we trusted Nadiehs great documentation for refilling it with the right numbers.

Going to Amsterdam

We were both ready to go and on our way from Haarlem to Amsterdam we made our outline and export so we could mill right away if we were in Amsterdam. I really had trouble getting the right outline and some extra space around the drawing, but luckily Nadieh had already finished and helped with the right settings. Putting a margin around the board and drawing a filled shape for the outline drawing. Export the copper-layer and user-drawing as svg Then in Illustrator open the saved files and export as png 1000. Here it is important to export the whole art-board. Get everything milled new milling nachine, quite rough Changing the updi

Collecting the components

monday-evening

Cleaning up the rough plate

Soldering Finding out that updi does not fit Fixing it with wire I worked my way towayrd being able to hook up my echo-module. I tried spirally to upload some code through the UPDI but it did not work, I thought I pick up my multimeter to test, but realised when I wanted to start that my ground-thread was bridged and the bridge was not there yet.

Tuesday-morning

Resoldered my board with a new place for the UPDI and had quite some trouble reconnecting the UPDI (the copperlayer came loose braking of both UPDI and Ground footprint, then I connected only to half of the 'ground' but with an extra 0 ohm resistor I reconnected both halves.

My own Sensor-box

I Bought myself a great sensor kit, so now I can put all the sensors I want on the SensLu Luxe sensor set met 37 verschillende sensoren

  • Small passive buzzer module KY-006
  • 2-color LED module KY-011
  • Hit sensor module KY-031
  • Vibration switch module KY-002
  • Photo resistor module KY-018
  • Key switch module KY-004
  • Tilt switch module KY-020
  • 3-color full-color LED SMD modules KY-009
  • Infrared emission sensor module KY-005
  • 3-color LED module KY-016
  • Mercury open optical module KY-017
  • Yin Yi 2-color LED module 3MM KY-029
  • Active buzzer module KY-012
  • Temperature sensor module KY-013
  • Automatic flashing colorful LED module KY-034
  • Mini magnetic reed modules KY-021
  • Hall magnetic sensor module KY-003
  • Infrared sensor receiver module KY-022
  • Class Bihor magnetic sensor KY-035
  • Magic light cup module KY-027
  • Rotary encoder module KY-040
  • Optical broken module KY-010
  • Detect the heartbeat module KY-039
  • Reed module KY-025
  • Obstacle avoidance sensor module KY-032
  • Hunt sensor module KY-033
  • Microphone sound sensor module KY-038
  • Laser sensor module KY-008
  • 5V relay module KY-019
  • Temperature sensor module KY-001
  • Temperature sensor module KY-028
  • Linear magnetic Hall sensors KY-024
  • Flame sensor module KY-026
  • Sensitive microphone sensor module KY-037
  • Temperature and humidity sensor module KY-015
  • XY-axis joystick module KY-023
  • Metal touch sensor module KY-036

With the sensor-kit and a bunch of wires,I am getting my old program from the Hello-Elvis board working on my SensLu-board and I am able to change it for different inputs.

Trouble with serial connection

Still no connection with rx/tx I asked around for a very basic program that does work with one of the other students. Nadieh sent me her simple program:

 1//Read out the Hall Effect sensor
 2#define pin_hall 3
 3int sensor_value_magnet = 0;
 4
 5void setup() {
 6  Serial.begin(9600);
 7}//void setup
 8
 9void loop() {
10  //Get the value from the Hall effect sensor
11  sensor_value_magnet = analogRead(pin_hall);
12  Serial.println(sensor_value_magnet);
13
14  delay(30);
15}//void loop

BUt it is not working, I am not trusting the ftdi, and will try to check that.

Checking the ftdi

to see what USB devices are hooked up to the computer ls /dev/tty.*

download for a terminal FTDI serial viewer https://ftdichip.com/drivers/vcp-drivers/

I tried using terminal for reading the serial outcome.

1ls /dev/ | grep cu.usbserial
2screen /dev/cu.usbserial-FTDYUKSO <options>
3-f 9600,cs8,-parenb,-cstopb,-hupcl

I tried it in different ways, with several tutorials online but did not get it to work, nor the information needed to check where I should start debugging.

In one of the tutorials the FTPI-serial was tested with coolterm, there was not a lot on information on that, but after searching on coolmac and testing I found a great tutorial on how to test my device. However I found that the serial is nicely echoing through the FTDI and a wire from RX to TX. https://www.mac-usb-serial.com/docs/tutorials/access-serial-port-on-mac-with-coolterm.html

The FTDI is working, so it is somewhere in the connection with the pins. I don’t understand it.

Loes and I worked together on the Waag and found that maybe it has to do with serial-swap. I don't quite understand what was wrong. but in the afternoon we thought maybe we just go back to the echo-ing. serialswap is working with the echo and on the updi, so maybe it is possible to use that anyway.

Now my 'old lightsensor-LED-setup' is working again but I cannot read it with my updi.... now try the ftdi.


Wednesday at Waag

Loes and I worked together and she is also not able to get it working, maybe we’ll work together on Wednesday in Amsterdam.


The result

The main problem was that my tx and rx where all messed up and I could not get it right anymore. Also the FTDI's that we have are very instable, so I never know what is not working, the board, the connections or did the FTDI get kicked off the usb-port. Eventually I got it working, a week or so later, but not with this confused T/RX-board. But with my good old HelloElvis board I did get it to work. I had to reconnect the wires in the ftdi by hand, and I could read the light sensor on my screen. The setup - with the serial-output on the screen- the code I used to get teh serial working on my good old elvis board. And a screenshot of the high and low light situations

the code:

 1#define photo_pin A3
 2
 3int sensor_value = 0;
 4
 5void setup() {
 6  // Initialize serial communications at 9600 bps:
 7  Serial.swap(1);
 8  Serial.begin(9600);
 9  while(!Serial);
10  
11  pinMode(photo_pin, INPUT);
12}//void setup
13
14void loop() {
15  sensor_value = analogRead(photo_pin);
16  int mapped_value = map(sensor_value, 0, 1023, 0, 255);
17  Serial.println(mapped_value);
18  delay(100);
19}//void loop

During the interface and application week I used it a lot more. And of course during the final project, where I used the serial connection all the time.


Learnings this week

  • I learned a lot about the bat-detector, and also that it was a bridge too far for my input-week
  • I love the idea that I can put any kind of sensor to my board and test it and play around with it.
  • It is wonderful to see that although I was very unhappy with Kicad last time I was able to work with it this time
  • It is very dissapointing if one piece of the board is not working and I cannot seem to find what it is.

here are the links to the designfiles of this week: