Batmonitor » History » Version 9

Txinto Vaz, 11/13/2014 12:24 AM

1 1 Txinto Vaz
h1. Construction of a BATmonitor
2 1 Txinto Vaz
3 1 Txinto Vaz
{{>toc}}
4 1 Txinto Vaz
5 1 Txinto Vaz
Present mini-project will develop a Battery monitor using an Arduino Uno R3 and the uCANca tools.
6 1 Txinto Vaz
7 1 Txinto Vaz
To build a testable circuit, we will implement a solution like this one:
8 1 Txinto Vaz
9 1 Txinto Vaz
http://arduino.cc/en/Tutorial/ReadAnalogVoltage
10 1 Txinto Vaz
11 1 Txinto Vaz
After we have played with the potentiomenter, the idea is to switch the input to monitor the battery level of a robot or toy controlled by the Arduino.
12 1 Txinto Vaz
13 1 Txinto Vaz
h2. Project creation
14 1 Txinto Vaz
15 1 Txinto Vaz
We will create a project called BatMonitor in uCANca.
16 1 Txinto Vaz
17 1 Txinto Vaz
!Bat01.png!
18 1 Txinto Vaz
19 1 Txinto Vaz
And add ourselves as team member (as contributor).
20 1 Txinto Vaz
21 1 Txinto Vaz
!Bat02.png!
22 1 Txinto Vaz
23 5 Txinto Vaz
h2. Functions specification
24 5 Txinto Vaz
25 1 Txinto Vaz
Add the main function of the system: Monitor the battery voltage value.
26 1 Txinto Vaz
27 1 Txinto Vaz
!Bat03.png!
28 1 Txinto Vaz
29 1 Txinto Vaz
!Bat04.png!
30 1 Txinto Vaz
31 1 Txinto Vaz
Add the secondary function of the system: Discretize battery voltage values into different battery ranges.
32 1 Txinto Vaz
33 1 Txinto Vaz
!Bat05.png!
34 1 Txinto Vaz
35 1 Txinto Vaz
Add a diagnostics function on battery: Warn (and register) battery low levels.
36 2 Txinto Vaz
37 2 Txinto Vaz
!Bat06.png!
38 3 Txinto Vaz
39 3 Txinto Vaz
And another diagnostic function for battery high:  Warn (and register) battery high levels.
40 3 Txinto Vaz
41 3 Txinto Vaz
!Bat07.png!
42 3 Txinto Vaz
43 3 Txinto Vaz
As summary:
44 3 Txinto Vaz
45 3 Txinto Vaz
!Bat08.png!
46 4 Txinto Vaz
47 4 Txinto Vaz
To make the system more testable, we will introduce a function that uses the LED to inform of the current situation of the system:
48 4 Txinto Vaz
49 4 Txinto Vaz
!Bat09.png!
50 6 Txinto Vaz
51 6 Txinto Vaz
h2. Technical concept
52 6 Txinto Vaz
53 6 Txinto Vaz
We will use an arduino uno R3 as microcontroller containing the software.  We will have a module that reads the input from the ADC and infers the voltage value (as described in F1).  Another module will select the current unfiltered battery level (as described in F2).  Then a time filter will be applied to select stable values of battery levels (debouncing system for F2).  No hysteresis, just time filtering.  After that battery level is selected, a FSM algorithm will determine if the high/low battery level failure is present (after qualifying for a certain time in the specific low/high range), or has dissapeared (as described in F3 and F4).  The FSM will also save the occurrence.  And finally there must be another module that will control the blinking LED (according to F5).
54 6 Txinto Vaz
55 6 Txinto Vaz
We can use a tool like XCos or yEd to make and understandable diagram of the desired solution technical concept.
56 7 Txinto Vaz
57 7 Txinto Vaz
In this case we will use XCos:
58 7 Txinto Vaz
59 7 Txinto Vaz
!Bat10.png!
60 8 Txinto Vaz
61 8 Txinto Vaz
!Bat11.png!
62 9 Txinto Vaz
63 9 Txinto Vaz
warning. Due to Scilab/XCos error, the input names of the BATLevel2LED_Coder block are not correctly shown.  By order(top to bottom): BatHigh_present, BatHigh_occurrences, BatLow_present, BatLow_occurrences.