Arduino is a circuit board that has a microcontroller on it and is used in many projects. A microcontroller is an integrated circuit that is basically a tiny computer that can run a single software program many times. A software program must be written using the tool and then downloaded to the microcontroller to perform a specific task. Writing a software program or code is easy for some group of people and difficult for another.

Is there a way to use Arduino without writing a code and perform any task? Yes, there is, Altair Embed software is a platform where No Hand-Coding is Required.

With Altair Embed, you can quickly develop the requirements of your project in the form of models. Models are built by simply sliding blocks into the work area and wiring them together with the mouse. Altair Embed communicates with the Arduino board through an USB cable. The key feature of Altair Embed automatically converts the control diagrams into C-code ready to be downloaded to the target hardware. Embed’s code generator allows you to easily try out new algorithms on a target hardware without the need of hand-coding. The generated C-code is recognized for its efficiency with respect to memory requirements and runtime.

Capabilities of Altair Embed with Arduino

  • Diagram to code (No hand coding is required)
  • Supports different Arduino board like Uno, Mega 2560, Leonardo
  • Obtains analog and digital data value from Arduino board
  • Support ADC (Analog to Digital Converter) with different frequency
  • Configure any ATmega pin as digital I/O
  • We can call any library function or user defined function using extern block
  • Support peripheral communication like I2C, SPI, UART with different config option
  • Control other devices with digital and PWM (Pulse Width Modulation) signals (like dimming an LED, Speed of dc motor/servo/stepper motor)
  • Simulation block for analog in, GPIO in, GPIO out, PWM

How Altair Embed interacts with Arduino?

Altair Embed software is a proven tool for developing embedded systems, by automatically generating code from block diagram models and transferring to popular controller hardware like Arduino. we will see how Altair embed interacts with Arduino with an example which illustrate how PWM is used in dimming an LED.

Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means or a square wave, a signal switched between on and off. PWM is mainly used to control the power that is supplied to various electronic devices.

The two main characteristics of PWM signal are

  • Duty cycle or modulation
  • Frequency

Duty cycle

Duty cycle is the amount of time the signal is in “on” state for the total period and is calculated as a percentage. Pulse width is difference of start time and end time in an “on” pulse. As the pulse width increases, output voltage increases and vice versa.

Frequency

Frequency is inverse of a period. In other terms, it is number of cycles per second and measured in Hertz (for example 100hz would be 100 cycles per second).

Working

In this case, LED dimming depends on the duty cycle (which varies the pulse width) and frequency (which varies the number of cycles per second) that is sent to an LED. A microcontroller sends a pulse at a certain frequency and certain width turning the power supply off and on. When the power supply is turned on, it sends a current through the LED and the voltage is high and when it is off no current is sent and the voltage is 0 v.

Requirements

Altair Embed Software, Arduino UNO, LED, Resistor (220 ohms), Connecting wires.

Circuit Connection

To have better prospects of dimming a LED, we use an external LED instead of the LED-on the Arduino board. The connections needed are –

  • Connect Arduino board to your computer
  • Connect one end of the resistor (220 ohms) to an LED and another to pin 3 to power up the LED.
  • Connect another end of a LED to ground.

To create a block diagram in Altair Embed

Let’s create a block diagram and see how Altair Embed communicates with Arduino. We need four blocks in Altair Embed to perform this task.

  • Arduino config block- The first step is to set up a config block of Arduino in Altair Embed, to define that this block is running for an Arduino and to generate code for it. Drag and drop the Arduino config to the main window. This pops up a window of Arduino properties.
    • Select the type of Arduino used. In this case we use Arduino Uno.
    • Select the virtual comport which chooses the serial communication port. This is automatically set for every one’s computer when Arduino is connected to any port, click ok to have Arduino config block ready.
  •  PWM block – Add the PWM block in a diagram and set it to any one of the PWM pins (for pin mapping refer Arduino.cc pin mapping website) . This block gives information about the duty cycle, which is 8.16% in this case
  • Triangle block -The triangle wave is used to dim an LED from zero to 100 percent dim. (This block is used to set the frequency for dimming an LED)
  • Convert Block – The PWM block accepts a scaled integer (fixed point) 8.16 input. So, we need to convert the triangle wave output to 8.16 scaled integer. For this use a convert block, double click on convert block, select scaled integer 8.16 and say ok. Make the wiring connection between blocks as shown

Click tools, code gen and compile, this generates the code from the block diagram. Hence no Hand-Coding is required. Click download to download the code to Arduino board. Make the circuit connection as described above. We can see the full dimming of a LED.

Refer the link below to understand the introduction of PWM using Altair Embed and the steps to create the block diagram and the circuit connection need for dimming an LED with Arduino using Altair Embed.

https://learn.solidthinking.com/embed-videos/arduino-series/dimming-an-led-with-arduino/

 

Click here to download!
Click here to download!

Have a question or comment?

Post your comment/question on our user forum.