Individual assignment

Measure something: add a sensor to a microcontroller board that you have designed and read it.

I chose a flex sensor to make this practice. LINK

Because of the circumstances we are going through I decided to use my last PCB.

Programming

We were getting some extra help from our group by on-line.

Understanding the FTDI chip

The FTDI chips implement the USB protocol stack. The responsibility of this hardware is to tell your PC what it is (using some identification information) such that your computer can load the right driver for it, and also to manage the data transactions with the PC there-on after - look up USB endpoints for a better explanation of these processes.

Once those drivers are loaded, this would specify a command set that your PC can use to query the chip. This hardware takes care of one side of the equation (communication with your PC). The other side of it would be some dedicated hardware to manage the UART protocol which includes logic, buffers and line drivers and the sorts. The command set mentioned earlier would be used to read from or write to the UART hardware. It should probably be mentioned that USB devices are polled by the PC, so in instances where you are using code which is event based, your PC is actually doing some polling to determine that new data has arrived - this may be different than a native serial port, I wouldn't know.
The above logic can be implemented either as a dedicated ASIC or by using a stripped down microcontroller core which executes firmware on ROM. If it is indeed a microcontroller core, then I imagine the UART is connected to it as a peripheral.

LINK

I had to use soldering to connect the FTDI with the PCB

Then, more programming

Afterward, it didn't work.

//Practice flex sensor, first try
							//int i = 0; 
							void setup() {   pinMode(A0, INPUT); 
							pinMode(11, OUTPUT);  
							pinMode(9, OUTPUT);   
							pinMode(10, OUTPUT); 
							}  void loop() {   if (analogRead(A0) <= 55) {     analogWrite(11, 51);
							analogWrite(9, 51);
							analogWrite(10, 255);
							} else {     if (analogRead(A0) <= 58) {       analogWrite(11, 51);
							analogWrite(9, 204); 
							analogWrite(10, 0);  
							} else {       if (analogRead(A0) >= 62) {         analogWrite(11, 255); 
							analogWrite(9, 0);   
							analogWrite(10, 0);   
								
							
//Practice flex sensor, second try
								//#include 

									SoftwareSerial ftdi(1, 0); // RX, TX
									
									int valor=0;
									double flex=0.0;
									
									void setup() 
									{
									  ftdi.begin(9600);
									  pinMode(0,OUTPUT);   //Configuracion del pin
									  digitalWrite(0,LOW); //Inicia el pin en un estado bajo 0 logico o 0 voltios 
									}
									
									void loop() 
									{
									  valor=analogRead(A3);
									  flex=(valor*5.0)/1024.0; 
									  flex=flex*100.0; 
									  ftdi.println(analogRead(A3)); 
									  ftdi.println(valor); 
									  ftdi.println(flex); 
									   ftdi.write("r");
									  
									  //flex = valor * 5.0 * 100.0 / 1024.0;  //  
									///  if(flex > 70.0) 
									///  {
										//apagar calefactor
										//enviar mensaje
										//digitalWrite(2,HIGH); 
									///    digitalWrite(0,LOW); 
										 
									///  }
									///  else
									///  {
									///    digitalWrite(0,HIGH);
									///  }
									  
									  delay(100); //delay 
									}  
									
								
//Practice flex sensor, third try
									//#include 

										SoftwareSerial ftdi(1, 0); // RX, TX
										
										int valor=0;
										double flex=0.0;
										
										void setup() 
										{
										  ftdi.begin(9600);
										  pinMode(13,OUTPUT);   //Configuracion del pin
										  digitalWrite(12,LOW); //Inicia el pin en un estado bajo 0 logico o 0 voltios 
										}
										
										void loop() 
										{
										  valor=analogRead(A3);
										  flex=(valor*5.0)/1024.0; 
										  flex=flex*100.0; 
										  ftdi.println(flex); 
											 // ftdi.write("r");
										  
										  //flex = valor * 5.0 * 100.0 / 1024.0;  //  
										  if(flex > 70.0) 
										  {
											//apagar calefactor
											//enviar mensaje
											//digitalWrite(2,HIGH); 
											digitalWrite(12,LOW); 
											 
										  }
										  else
										  {
											digitalWrite(12,HIGH);
										  }
										  
										  delay(100); //delay 
										}
										
									

I had to get more information during the classes to practice more with this flex sensor, I made a lot of tries and it was really hard to be honest, the only way to learned about was practice with the simulator, it was when I worked with TinkerCad and I used the different ways they ofered to get the code and test it. Anyway my plan for the final project was directed to apply the use of the flex sensor and for this reason I am showing this example on the video.

Conclusion

  • Worked during the pandemia with this assignment was very complicated becasue of the way we had to work, that´s why I used digital simulators to get this result.
  • I made some mistakes with the soldering, so now I always recheck every single way to avoid the future problems.
  • The better way to learn about this new stuff is work in a group, then you can learn about the way your classmates can teach you about the right way to fix problems.
  • After to try a lot of times to get the code the best way is being logic about the understanding on your directions.

Files