Showing posts with label resistor. Show all posts
Showing posts with label resistor. Show all posts

Sunday, December 20, 2020

Reading Potentiometer value using Arduino - Software Loading into Arduino and Demo

 In earlier article we have seen the software creation using pure Simulink with out using any Stateflow for reading and displaying the potentiometer value. In this article we will explore the software deployment, circuit diagram and demo.

Schematic for reading potentiometer value using Arduino

 Potentiometer wiper is connected to the Arduino analog pin 2, 5V power and ground is supplied from Arduino. Three LED's are connected to the Arduino digital pin 3,4 and 5 to display the potentiometer reading in binary format. When the processed analog value is 1 only first LED will be turned on and rest all LED's are turned off. So these three LED's represent the three bits of the binary number.

Software deployment to Arduino from Simulink 

Following video presents the steps required to prepare the Simulink model for code generation for the Arduino board. The steps for the code generation are same as the steps explained in this article


 Demo for Potentiometer value reading using Arduino


As you can see in the demo video the potentiometer value is read by the Arduino using the analog pin 2 and then process it and displayed the mapped value using three white LED's.

I hope you enjoyed the article and we will catch up in our next article where we will discuss the traffic lights simulation for four junction signals.

Sunday, December 13, 2020

LED Blinking using Arduino and Matlab - Software Loading into Arduino and Demo

 In previous post we have seen the steps to create the Simulink model for the LED Blinking. In this post we will learn about configuring and preparing the model for code generation and deployment to the Arduino board.

Steps for preparing the Simulink model for deployment to Arduino

 The following steps help you to prepare the model for the deployment to the hardware in our case Arduino board.

  • Open the model configuration parameters from the Simulation window or select the little triangle icon beside gear icon in the tool bar and select "Model Configuration Parameters"
  • Select the "Hardware Implementation" option from the right options pane
  • Next choose the "Hardware board" from the drop down list available in our case we will select the Arduino. It can be either Arduino UNO or Arduino Mega 2560 based on your board.
  • Click save for the model configuration parameters.
  • Select the C/C++ Code from the Code menu and then click on Deploy to Hardware option or you can simply press Ctrl+B to deploy the software to the hardware board.
  • After successful code generation the code generation report will be opened automatically and you can browse the code from the simple HTML window popped up. 
  • MATLAB automatically generated the hex file for the Arduino board and deploys it using the connected USB cable.

All the above listed steps are explained in the following video.


 Schematic

 The Arduino schematic is developed using Fritzing software and is as follows, Arduino digital pin 9 is connected to the anode of the LED and the cathode of the LED is connected to the ground via current limiting resistor.

LED Blinking Demo using Arduino

You can check the following video for the LED Blinking demo, as you can see in the video the LED blinks with 0.5sec cycle.


 I hope you enjoyed the LED Blinking project using Arduino, Simulink and Stateflow.

Friday, December 11, 2020

LED Blinking using Arduino and Matlab - Software Creation using Stateflow and Simulink

 In this article we will work on LED blinking program using Arduino. The software required for the LED blinking is developed using MATLAB/Simulink and Stateflow charts. 

The required components

  • One LED
  • Arduino
  • Connecting Wires
  • Resistor
  • Matlab or Arduino IDE

In this article we will use the MATLAB, Simulink and Stateflow to create the required software to blink the LED. In next article we will explore the same using Arduino IDE and C programming language.

Matlab has support for Arduino development and we can use the blocks from  "Simulink Support Package for Arduino". You can follow the below Matlab support article to get the blocks for Arduino

https://in.mathworks.com/hardware-support/arduino-simulink.html

Steps for creating the Simulink model for LED blinking

  • Create an empty model
  • Open the Simulink Library browser
  • Drag and Drop the Digital Output block from "Simulink Support Package for Arduino Hardware"
  • Drag and Drop the Stateflow chart to the model
  • The following video shows the step by step process


     
  •  Now we have seen how to create the software using Simulink and Stateflow and the next step is preparing the Simulink model for the code generation.
  • In our next post we will see how to prepare our LED blinking model for the embedded code generation and how to load the generated executable into Arduino Board.

Stateflow

  • Stateflow is MATLAB is used to create the state machines.
  • In above video we have seen how to use state and entry criteria to control the LED on and off.
  • entry condition in the Stateflow is used to set the state of the signals at start of the state and they will stay remained at the assigned values.

Reading Potentiometer value using Arduino - Software creation using Ardino IDE and C Programming Language

 In previous article we have seen the steps in creating the software for the reading Potentiometer value using Simulink for Arduino board. ...