Analogue

An app for the Kookaberry

Tony Strasser

Developed by
Tony Strasser

AustSTEM

This demonstrates proportional control using analogue inputs.

Directions

Step 1: Setup

Setup the app by plugging a potentiometer into P4 and a LED into P2.

                 

A servo can also be plugged into P1 to demonstrate proportional control, but this is currently a fiddly process as the servo is not equipped with a compatible jst connector. Adaptors will be provided with classroom kits but a connector lead can be made up as shown below.

The micro servo shown above takes very little current and can be powered directly from the Kookaberry’s battery when it is plugged into P1.

Making up a servo connecting lead

                   

A suitable lead can be made up by using the AustSTEM supplied 3-wire jst-to-Arduino lead, and and using small 1cm bits of electrical wire (individual strands of 30A electrical cable are perfect), or carefully cutting down pins to join the female Arduino connector on the AustSTEM lead to the female Arduino connector on the servo lead. Join the two together as shown in second screen shot above. Note that the connectors are turned over when joined together. When connected, wrap the joint with electrical tape.

Step 2: Running the app

Navigate to the Analogue app and press Button B to run

What is showing on the screen?

  1. Top Row: Name of the app
  2. Second Row:
    • % value of the analogue voltage being applied at P4
    • Histogram showing the % value graphically. An adjustable threshold level is shown as a % of a “full” histogram.
    • A light bulb icon is shown when the threshold level is exceeded. P2 is also turned ON.
  3. Third Row: Angle of servo arm when a servo is connected to P1. The angle of the servo arm is shown relative to 0 degrees – which is set at 50%.
  4. Fourth Row: Prompts for peripherals
  5. Fifth Row: Button A is Exit and Buttons C and D move the threshold value up or down.
Step 3: Using the app to turn a light on when a threshold is reached

Turn the potentiometer to vary the analogue input level at P4

         

In the screenshots above,

  • the first shows the LED OFF because the input level (36%) is below the 50% threshold level.
  • the second shows the LED ON because the input level (60%) is above the 50% threshold level. The LEED connected to P2 will alsp light up.
  • the third is the same as the first except that the threshold level has been reduced (by pressing Button C) to 25% and the input level is 20%.

The input can be any compatible analogue input such as a potentiometer, light sensor, hygrometer, sound sensor etc.

The output can be any compatible digital on/off device such as an LED, motor, buzzer etc.

Step 3: Using the app to demonstrate proportional  servo control

The Kookaberry reads an analogue input on P4 and displays its value as degrees (the value is shown under the larger % value) and turns the little plastic arm that is pushed onto the servo shaft. Turn the potentiometer to vary the rotation angle of the servo.

         

Turn the potentiometer until the display shows zero (0) degrees as per screenshot above (this is also 50% of the voltage output) and push the plastic arm onto the shaft of the servo in line with the body of the servo. Turning the potentiometer to the left or right moves the arm to its limits of approximately plus or minus 90 degrees.

How a servo works

[This explanation is courtesy of Osoyoo® Micro bit lesson — Using a Servo Motor]

Unlike the action of most motors that continuously rotate, a servo motor can rotate to and hold a specific angle until it is told to rotate to a different angle. You can control the angle of the servo by sending it a PWM (Pulse Width Modulation) pulse train; the PWM signal is mapped to a specific angle from 0 to 180 degrees.

Inside of the servo there is a gearbox connected to a motor that drives the shaft. There is also a potentiometer that gives feedback on the rotational position of the servo, which is then compared to the incoming PWM signal. The servo adjusts accordingly to match the two signals.

PWM operates by turning the digital output ON and OFF very quickly to simulate an analogue voltage. This varies the duty cycle of the pin (how much time it is spent in the ‘ON’ state)  If it spends an equal amount of time in the two states, the voltage looks like 50% of the available voltage, and the angle is zero

Peripherals used by this app

Learning plans that use this app

Version:1


Last updated:1 week ago


Device:Kookaberry


Radio code:


App ID:...


lib_dependencies:


root_dependencies:


Downloads


Download on GitHub
Image

Support

Issues resolved in the support forum:

8 out of 11
View support forum

Leave a Reply

Bitnami