Skip to content
Snippets Groups Projects
Commit 08a7ef18 authored by António Carlos Gomes Cintrão Gonçalves's avatar António Carlos Gomes Cintrão Gonçalves
Browse files

step response video

parent 6edac01b
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -111,8 +111,83 @@ Note that the wires are only a kind of switch: if we put it in water it will be
Listen to [Neil lecture video](https://vimeopro.com/academany/fab-2019/video/326957751) at 55:36, he introduce the step response mechanism and I was curious about it. So I manage to make the board and the cardboard and start to test it with the following arduino and processing programs:
(arduino)
```
/*
read analog voltage at pin A3 in two different times (ruled by ADC pin settling time);
*/
#include <SoftwareSerial.h>
int sense, sense_0;//variables to be measure at two different moments
int settlingTime = 3; //3 ms to wait for the signal to settle: 25 ADC clock cycles, ATtiny44 datasheet p.129 and 159
SoftwareSerial Serial(1, 2); // RX, TX serial communication
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode(A3, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(A3, LOW);
delay(settlingTime);
//Serial.println("LOW");
sense_0 = analogRead(7);//measure initial voltage
digitalWrite(A3, HIGH);
delay(settlingTime);
sense = analogRead(7);//Measure final voltage
float delta = settlingTime/1000.0;
float sloap = (sense - sense_0)/delta;//calculate sloap (rate)
//Serial.write(sloap);
Serial.println(sloap);
//Serial.println();
```
(processing)
```
// Adapted from the Tom Igoe example at https://processing.org/reference/libraries/serial/Serial_readStringUntil_.html
import processing.serial.*;
int lf = 10; // Linefeed in ASCII
String myString = null;
Serial myPort; // The serial port
void setup() {
size(400, 600);//window size
fill(255);// windo color
// List all the available serial ports
printArray(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[13], 1200);//choose the number of your serial in the list
myPort.clear();
}
void draw() {
while (myPort.available() > 0) {
background(0);
text("distance", 50, 80);
myString = myPort.readStringUntil(lf);//reading the serial data
if (myString != null) {
//println(myString);
float average = float(myString);
//println("average");
println(average);
square(average);//calling the square function
}
}
myPort.clear();
}
void square(float average){//moving bar
noStroke();
fill(255);
rect(50, 100, average/1000, 50);
}
```
!!! note
**pullup** resistor explained by Neil at 10:00 of this [lecture](https://vimeopro.com/academany/fab-2019/video/326957751)
......@@ -133,7 +208,8 @@ Listen to [Neil lecture video](https://vimeopro.com/academany/fab-2019/video/326
Conclusion:
With this arrangement touching is well detected. Distance not so good, but I think if we do an average, it could be better. Weight seem to work weel if I touch the GND as well as you can see at the video.
(put video here)
<iframe src="https://player.vimeo.com/video/349280387" width="640" height="480" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>
<p><a href="https://vimeo.com/349280387">stepResponseOneTouch</a> from <a href="https://vimeo.com/user17547355">Ant&oacute;nio</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
**Next step**: average the measures to get more accuracy.
......@@ -188,7 +264,7 @@ Cutout parameters:
I'm using MAC and I have been struggling with the toolchain since week 5. This week, with the Luis Carvão precious help, I manage to overcame the problem. The procedure was to show the problem, presenting what I have allready done and seek for newer debuging steps.
Problem:
- The main issue is that sommetime it work, other don't, in MAC or LINUX: I was debugig it using Linux, beacuse with this, and the help of Filipe I manage to get sucess, but not entirelly;
- The main issue is that sommetime it work, other don't, in MAC or LINUX: I was debugig it using Linux, because with this, and the help of Filipe I manage to get sucess, but not entirelly;
- It was not possible to upload the program using the ARDUINO IDE (on Mac as on Linux);
- When we managed to sucessed the Serial Terminal of the Arduino IDE didn't show the characteres properly;
- Since we were interchanged the circuit with MAC and LINUX computer we done the reset of the ATtiny and it seems to be working better;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment