Silicon ChipFlowcode Graphical Programming - April 2022 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Subscriptions: PE Subscription
  4. Subscriptions: PICOLOG
  5. Publisher's Letter
  6. Feature: Go eco, get ethical! by Mark Nelson
  7. Feature: The Fox Report by Barry Fox
  8. Feature: Net Work by Alan Winstanley
  9. Back Issues: Digital FX Unit by John Clarke
  10. Project: 64-KEY MIDI MATRIX by Tim Blythman
  11. Project: Digital FX Unit by John Clarke
  12. Feature: P955H PIC Training Circuit by Peter Brunning
  13. Project: High-current Battery Balancer by Duraid Madina
  14. Feature: Circuit Surgery by Ian Bell
  15. Feature: Flowcode Graphical Programming by Martin Whitlock
  16. Feature: AUDIO OUT by Jake Rothman
  17. Feature: Max’s Cool Beans by Max the Magnifi cent
  18. Feature: Make it with Micromite by Phil Boyce
  19. PCB Order Form
  20. Advertising Index

This is only a preview of the April 2022 issue of Practical Electronics.

You can view 0 of the 72 pages in the full issue.

Articles in this series:
  • (November 2020)
  • (November 2020)
  • Techno Talk (December 2020)
  • Techno Talk (December 2020)
  • Techno Talk (January 2021)
  • Techno Talk (January 2021)
  • Techno Talk (February 2021)
  • Techno Talk (February 2021)
  • Techno Talk (March 2021)
  • Techno Talk (March 2021)
  • Techno Talk (April 2021)
  • Techno Talk (April 2021)
  • Techno Talk (May 2021)
  • Techno Talk (May 2021)
  • Techno Talk (June 2021)
  • Techno Talk (June 2021)
  • Techno Talk (July 2021)
  • Techno Talk (July 2021)
  • Techno Talk (August 2021)
  • Techno Talk (August 2021)
  • Techno Talk (September 2021)
  • Techno Talk (September 2021)
  • Techno Talk (October 2021)
  • Techno Talk (October 2021)
  • Techno Talk (November 2021)
  • Techno Talk (November 2021)
  • Techno Talk (December 2021)
  • Techno Talk (December 2021)
  • Communing with nature (January 2022)
  • Communing with nature (January 2022)
  • Should we be worried? (February 2022)
  • Should we be worried? (February 2022)
  • How resilient is your lifeline? (March 2022)
  • How resilient is your lifeline? (March 2022)
  • Go eco, get ethical! (April 2022)
  • Go eco, get ethical! (April 2022)
  • From nano to bio (May 2022)
  • From nano to bio (May 2022)
  • Positivity follows the gloom (June 2022)
  • Positivity follows the gloom (June 2022)
  • Mixed menu (July 2022)
  • Mixed menu (July 2022)
  • Time for a total rethink? (August 2022)
  • Time for a total rethink? (August 2022)
  • What’s in a name? (September 2022)
  • What’s in a name? (September 2022)
  • Forget leaves on the line! (October 2022)
  • Forget leaves on the line! (October 2022)
  • Giant Boost for Batteries (December 2022)
  • Giant Boost for Batteries (December 2022)
  • Raudive Voices Revisited (January 2023)
  • Raudive Voices Revisited (January 2023)
  • A thousand words (February 2023)
  • A thousand words (February 2023)
  • It’s handover time (March 2023)
  • It’s handover time (March 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • AI, Robots, Horticulture and Agriculture (April 2023)
  • Prophecy can be perplexing (May 2023)
  • Prophecy can be perplexing (May 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • Technology comes in different shapes and sizes (June 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • AI and robots – what could possibly go wrong? (July 2023)
  • How long until we’re all out of work? (August 2023)
  • How long until we’re all out of work? (August 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • We both have truths, are mine the same as yours? (September 2023)
  • Holy Spheres, Batman! (October 2023)
  • Holy Spheres, Batman! (October 2023)
  • Where’s my pneumatic car? (November 2023)
  • Where’s my pneumatic car? (November 2023)
  • Good grief! (December 2023)
  • Good grief! (December 2023)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (January 2024)
  • Cheeky chiplets (February 2024)
  • Cheeky chiplets (February 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • The Wibbly-Wobbly World of Quantum (March 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - Wait! What? Really? (April 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - One step closer to a dystopian abyss? (May 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk - Program that! (June 2024)
  • Techno Talk (July 2024)
  • Techno Talk (July 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - That makes so much sense! (August 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - I don’t want to be a Norbert... (September 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk - Sticking the landing (October 2024)
  • Techno Talk (November 2024)
  • Techno Talk (November 2024)
  • Techno Talk (December 2024)
  • Techno Talk (December 2024)
  • Techno Talk (January 2025)
  • Techno Talk (January 2025)
  • Techno Talk (February 2025)
  • Techno Talk (February 2025)
  • Techno Talk (March 2025)
  • Techno Talk (March 2025)
  • Techno Talk (April 2025)
  • Techno Talk (April 2025)
  • Techno Talk (May 2025)
  • Techno Talk (May 2025)
  • Techno Talk (June 2025)
  • Techno Talk (June 2025)
Flowcode Graphical Programming Flowcode C void interrupt(void) { if (intcon & 4) { clear_bit(intcon, 2); FCM_INTERRUPT_TMR o(); Assembly movlw D′7′ bsf STATUS, RP0 bcf STATUS, RP1 movwf _adcon1 movlw D′192′ movwf _option_reg Hex :040000008A01122837 :08000800F000F00S030 EF10000 :10001000040EF2000A0 EF300BA110A122928352 86C :2000200D928FE28073 Programming with Flowcode – Part 3: LCD temperature monitor T his month, we will expand our use of Flowcode by showing how to use a PIC16F88 and RedBoard/ Uno to measure the output of an analogue sensor and display it on a 16x2 LCD alphanumeric display. The sensor we have chosen measures temperature, but similar principles would apply to analogue voltages from other sources. Do note that we are following on from Parts 1 and 2 in the January and February 2022 issues of PE. To avoid a lot of tedious repetition we will not rehash the ideas already covered, so you do need to have read those articles to get the most out of this project. (We will, however, provide some handy links to refresh your memory.) Last, but not least, all the components used are in the ‘free’ section of Flowcode – no purchase needed! (See the box at the end of this article for further details.) Sensor and display choices budget. (See this month’s Circuit Surgery for more insight into the LM35.) For the 16x2 (16 columns, 2 rows) display, we will use an LCD based on the Hitachi HD44780 parallel interface LCD controller chip. The display connection pins used will be the same regardless of the display size you use. For example, a 20x4 LCD uses the same pins as a 16x2 device. Fig.1 shows a typical 16x2 LCD. These LCDs operates in two modes: eight-bit and four-bit. The number of bits determines how many data pins are used. We will use four-bit mode via the four data pins D4 to D8, (eight-bit mode would use all eight data pins, D0 to D7). Project overview We are going to create a flowchart that reads the voltage on the microcontroller analogue input pin which is connected to the sensor, and then on the LCD, show the Celsius temperature and one of three messages: ‘Too cold’, ‘Just right’ or ‘Too hot’. Also, three microcontroller pins (A0, A1 and A2) are assigned to message indicator LEDs (via 330Ω current-limiting resistors). Fig.1. Typical 16x2 LCD. Fig.2 shows what the Flowcode 2D Panel will look like when the project is completed and running in simulation mode. Designing the flowchart Let’s get started on the Flowcode design. (Again, remember that I am assuming you have read Parts 1 and 2.) First, run Flowcode and select New Project, the last target device used should be in the new Embedded Project window. If it is not the one you want (PIC16F88) then right-click any device in the Choose a Target section and search for your device – see First Steps in PE, January 2022, p.39. If you are using a RedBoard/Uno, make sure the correct com port is selected (see PE, January 2022, p.41-42). Flowcode libraries include different types of temperature sensors which fall into two distinct categories: analogue and digital. For analogue sensors, the output voltage is proportional to the measured temperature, and it interfaces to a single microcontroller ADC pin. (Note that what I’m discussing here are not sensors like thermocouples or thermistors, but their IC equivalents; for example, the well-known LM35.) The output of digital sensors is either 0, 5V or 3.3V depending on the sensor and microcontroller used. In this project we take the analogue option via the popular LM35 sensor from Texas Instruments, but the free Flowcode component we use can support all of the following temperature sensor ICs: AD22100, AD22103, LM135, LM235, LM335, LM35, LM60, MCP9700, MCP9701, TC1047, TMP35, TMP36, TMP37 and TSIC301. These devices provide varying degrees of accuracy, linearity and range – you choose the one best suited to your application and Fig.2. Simulation of the LM35-based temperature display running on the Flowcode 2D Panel. Practical Electronics | April | 2022 49 connections of the LCD. For example, the connection for Data 0 goes from pin B0 of the microcontroller to pin 11 on the LCD. Variables Fig.3. Searching for an LM35 will bring up an ‘Analogue Temp Sensors’ device. Whichever microcontroller you choose, ensure it is set with the same parameters, for example clock speed, as used in Part 2. Components The first step in creating a project is adding the required components. The easiest way is to select the Components Libraries Ribbon and then use the search tool. We need the following four components: Analogue temperature sensor – search for one of the free temperature sensor ICs listed above, for example ‘LM35’ or ‘TMP36’. Note that when you have found your device it will appear with the label Analogue Temp Sensors (see Fig.3). Display – Search for ‘LCD’. To keep this cost-free, scroll down to LCD (Generic, 16x2) for a two-row device, or for four rows, use Combo (BL0114). If you choose the 16x2 device, then the component name that appears in the 2D Panel is lcd_16x2. LEDs – Search for ‘LED’. The free version is LED (5mm, Panel); we will need three. Static text – search for ‘Static’, add one component, resize and then copy and paste twice from the 2D Panel. To edit text, right-click and select properties and then change the default ‘sample text’ to the text you want. When the correct component is found, right-select it and add it to the 2D dashboard panel. If you need multiple components of the same size, it’s quicker to add one component, adjust its size, and then copy and paste it on the 2D Panel. Likewise, if you have multiple components you would like to resize by the same percentage, hold the shift key and select the components you want to process. Now select the resize icon. Arrange your components so that the 2D dashboard panel looks like Fig.2. I drag the components to roughly the correct position and then fine tune them using ‘Position’ from Properties (see PE, January 2022, p.42) Next, change the LEDs to the correct colour and rename them (see PE, January 2022, p.43) to match Fig.2. Make sure the connections are correct for all the components (see Table 1). The numbers in brackets are the pin 50 As well as components, we need to create the variables required for the project, and for good practice initialise them, even though not all of them actually require it. The variables used are shown in Table 2. Refer back to February 2022, p.38-39 for details on how to set up variables. There are three kinds of variable here: Component PIC16F88 RedBoard/Uno Too cold A0 D5 = Digital 5 Just right A1 D6 = Digital 6 Too hot A2 D7 = Digital 7 Temp Sensor A4 C4 = Ana 4 Data 0 (11) B0 B0 = Digital 8 Data 1 (12) B1 B1 = Digital 9 Data 2 (13) B2 B2 = Digital 10 Data 3 (14) B3 B3 = Digital 11 LEDs LCD Register Select (4) B4 B4 = Digital 12 Byte – these are 8-bit, unsigned numerical values Enable (6) B5 B5 = Digital 13 that can have a value from Table 1. Component-PIC/RedBoard connections. 0 to 255. Int – these are signed numerical values that can have a value from –32678 to 32677. Variable Name Type Initilise Value Offset Byte 0 State Byte 0 String – these contain not TempInt Int 0 just numbers, but also othTempString String [Array length = 5] er characters, often letters from the ASCII code and Table 2. Flowcode project variables are typically used for short pieces of text To do this, just select Properties In our temperature display project, we from a blank area of the 2D panel or are going to use four variables: select Properties from the View ribbon. Next, select the drop-down outlined Offset – used in Calculation boxes to set in blue in Fig.4, and click on New the level of switching hysteresis. category. Now enter a suitable name – Temperature C x10. Select the State – result from the Calculation box spanner folder, click on Add new and that is used by the Switch. make the following settings: TempInt – represents the temperature value after x10 processing (see below). Cosmetic name – type in a name (you can use spaces); for example, Too hot. TempString – text message displayed on the LCD. Property type – choose Signed integer. When you declare a string variable you need to define the maximum number of characters used, in our case this is 10. As detailed last month, click Global Variables in Project Explorer and when the pop up window appears, choose ‘String’. Name the string TempString, and in array length enter 5, then select Add Array Dimension. You should now see TempString[5] for the string name. Last, we need to assign values to a pair of Properties. These are the low and high temperature settings, which are used to trigger the LEDs and messages. We do this by adding these variables to the Properties of the 2D Panel. Property variable – this is the variable’s name, but note that that spaces or starting with a number are not allowed; for example, use TooHot. Fig.4. Adding the low and high temperature settings variables. Practical Electronics | April | 2022 2. Initialise the LCD All components in Flowcode that have initial parameters must be initialised at the start of the program – an LCD is such a component. Therefore, the first component function to be added initialises the LCD. We do this with the Component Macro lcd_16x2 Start. You can find it by looking at the display component’s list of Component Macros – click the ‘+’ in the little square to the left of the lcd_16x2 component in Project Explorer (Fig.6). Now, from the bottom of the list, drag the Start Component Macro to underneath Begin in Main. Fig.6. Locating l c d _ 1 6 x 2 St a r t , the LCD’s initialising LEDs do not need to be ini- Component Macro. tialised to operate properly, but for the project to work correctly we do need to set their initial state. The initial state for the three LEDs is off. 3. Set the LED initial conditions 4. Start an endless loop 4. Next, drag a Loop from the Command icons and place it below the LEDs’ initial state functions. Fig.5. Building the first part of the flowchart. Now you can set the high-temperature limit value, which is 245 for TooHot. Repeat this process for a temperature setting called Too cold and use TooCold as the variable name, with value 180. You should now have created what is shown in Fig.4. Software development 5. and 6. Measure temperature and write to LCD Now we turn to reading the sensor in degrees Celsius and writing it to the LCD. The next stages involve more Component Macros. These are found in a similar way to lcd_16x2 Start described above. The following Component Macros are dragged inside the main loop in the following order, top to bottom: AnalogueSensor1 GetTempIntCX10 – multiplies the temperature value by ten and assigns the result to a variable called TempInt. (See below for an explanation of why this is done.) Before we get into the nitty-gritty of flowchart building, let’s define what we want the software to do. There are eight main components to the software: AnalogueSensor1 GetTempStringC – assigns the temperature value as a string (eg, ‘24.8’) to a variable called TempString which is used by the LCD to display the temperature. 1. Begin and End, which are common to all programs, and are built into the Main Macro 2. Initialise the LCD 3. Set the LED initial conditions 4. Start an endless loop, inside which the following three steps are performed 5. Measure temperature 6. Write the temperature to the LCD 7. Compare temperature with set parameters, then turn on one LED according to the temperature and write one of three messages to the LCD 8. Return to start of loop. lcd_16x2 Cursor x,y – defines the cursor starting position: x = column, y = row. We use lcd_16x2 Cursor 4,0 – note the x position values start at 0, so for 4,0 the cursor will start at the fifth (not fourth) location from the left, and in the first row. Refer back to Fig.2 – this is the location of the number ‘2’ in ‘21.8’, thus helping to centre the displayed value. Let’s run through each of these in turn and build up our temperature display program. 1. Begin and End Remember, in Flowcode, the whole program lives within a Macro called ‘Main’ (see top of Fig.5). If you examine Main immediately after creating a new project, it will just contain the Begin and End icons. All the components we need to add are placed after Begin. Practical Electronics | April | 2022 lcd_16x2 PrintString – uses the TempString variable to print the temperature value to the display. lcd_16x2 PrintString – uses the same Component Macro again to print ‘C ’ Note the single space after the ‘C’, which is used to ensure all of the previous temperature value characters are overwritten. The reason behind the need for the times-ten Component Macro AnalogueSensor1 GetTempIntCX10 is that it allows us to convert a floating-point variable like 24.5 into an integer version without a decimal point; ie, 245. Unfortunately, floating variables with decimal point takes up a lot of memory and for that reason, we are unable to use them on the PIC16F88. Using an integer version allows us to get round this problem. 51 on the ‘Too hot’ LED. If No, then the next Decision branch asks if the temperature is too cold – if yes, then turn on the ‘Too cold’ LED. If No, then turn on the ‘Just right’ LED. There is a subtle problem with this simple approach to switching LEDs on/off based on a temperature threshold. If the temperature lies on the border between two states (eg, ‘Just right’ and ‘Too hot’) then the output of the PIC’s ADC may oscillate between two very closely matched values and cause the LEDs to blink. This is not really a serious problem if all you are doing is switching LEDs, but if you were switching relays or larger equipment it could be a real problem to repeatedly switch devices on and off in rapid succession. The answer to this kind of problem is to add some hysteresis. With this in mind, our Decision branches use the following two expression: TempInt - Offset >= TooHot TempInt + offset <= TooCold Fig.7. Add text to Pr i n t St r i n g using the Expression box. We need to add several different pieces of text to the lcd_16x2 PrintString Component Macros. To do this, go to the Components listing in Project Explorer, scroll down to lcd_16x2, open the component list and drag lcd_16x2 PrintString to where it will be used. When you release the Component, a Properties window will open. In the Expression section of the pop up window, enter the required text inside double quote marks; ie, “Too hot ”, see Fig.7. Note – there’s one exception to the double quote mark rule. When adding the lcd_16x2 PrintString Component Macro for TempString in Fig.5, do not use double quotes. Instead, use the Expression drop-down and select TempString. It is the Offset that adds the crucial hysteresis, which is used to suppress potential oscillation. When the temperature is rising, from Just right to Too hot, Too hot must be 0.6 degrees hotter than the 245 (ie, 251) Too hot setting to trigger the Too hot LED/message. When the temperature is falling from Too hot to Just Right, the trigger is ‘just under’ 245. Likewise, when the temperature is falling from Just Right to Too cold, the trigger point is 0.6 degrees colder than the 180 Too cold setting (ie, 174). When the temperature is rising from Too cold to Just Right, the trigger is ‘just over’ 180. To add the items in Fig.8. First drag a Decision (from the Command Icon section, see PE, February 2022, p.40) to underneath the lower lcd_16x2 PrintString Component Macro (in Fig.5). Next, add the second Decision, but ensure it is above the first Decision’s ‘return square’ – ie, it is nested inside the first added Decision. Double click the Decisions and add the hysteresis expressions. Next, add the (rectangular) Calculation boxes (from the Commands Icon section). Double click on each one and the Calculation window will pop up. Drag the two variables State and Offset from the right-hand side of the window under Global Variables to the blank left-hand side of the pop up (see Fig.9). Next, edit Offset so that it says Offset=0 (or Offset=6). Likewise, edit State so that is says State=1 (or 2, or 3). You should now have created the contents of Fig.8. Calculation Component Macros Fig.8. Building the Decision/Calculation branches. Note: In Fig.5 I edited the loop Component Macro labels (above-right of the green boxes) in the second and third components. For example, I used Get temperature C x10 to make the flowchart easier to read. It is good practice to add little reminders and annotations as you proceed with a flowchart. When you have added all these items check that your flowchart matches Fig.5. So what do the three Calculation boxes mentioned above do? Their purpose is not to directly turn on or off LEDs, or send messages to the LCD, What they do is set variable values that are picked up by the next item in the flowchart – a Switch component – which contains User Macros that do control the LEDs and LCD messaging. Now move on to Fig.10, which is placed immediately after the decision branches section. It uses the State variable from the Calculation boxes and there are three possible outcomes depending on the value of State. 7. LEDs and messages The next step is a bit more complex, here we will set up the Decision branches that select which LED to illuminate and which message to send to the LCD. For the following description, refer to Fig.8, which follows on directly after the bottom of Fig.5. There are two kinds of operation in Fig.8. First, the Decision branches. The program asks if the temperature is too hot; if it is, then turn Fig.9. Adding Of f s e t and St a t e in the Calculation Properties window. 52 Practical Electronics | April | 2022 Parts list – PIC16F88 circuit PIC16F88 LCD 1602 (or 2004) with HD44780 chipset LED red LED green LED blue Crystal 196608MHz Resistor 330Ω x3 Capacitor 22pF x2 Capacitor 100nF Trimmer 10kΩ Solderless breadboard Fig.10. The Switch component has three branches controlled by the St a t e variable. The Calculation boxes can generate one of three State values: 1, 2 or 3 in response to the Decision results. For example, if the first Decision answer is ‘Yes’ to the question, ‘is the temperature too hot?’, then State = 3. Likewise, if the second Decision answer is ‘Yes’ to the question, ‘is the temperature too cold?’, then State = 1. The way Switch works is that when it reads the variable State, the only Switch branch accessed by the program is the one that matches the value of State. This accessed branch contains a User Macro that then lights the appropriate LED and sends the correct message to the LCD. To build the section shown in Fig.10 we must first create our User Macros. Start by adding three User Macros, as shown in Fig.11. (We covered User Macros in PE, February 2022, p.38). Next, to assemble the Macros, copy the flowcharts in Fig.12, paying attention to the settings. (LEDs were covered in PE, February 2022, p.38.) Do pay attention to adding the spaces in the lcd_16x2 PrintString Component Macros. The use of spaces is particularly important to get the LCD to display text messages properly. For example, if the display shows ‘Just right’, but then changes to ‘Too hot’. Without spaces in the TooHot user macro, the display will show ‘Too hotht’ because the ‘ht’ of ‘Just right’ is not overwritten with spaces. Now we can add the User Macros to the Switch. Double click the Switch Fig.11. Adding three User Macros in Project Explorer. and the Properties window will appear. From the Switch dropdown, select Global Variable State. Next tick the first three ‘Cases’ and the three State values will appear by default. Click OK. Next, drag your three User Macros to the appropriate Switch branch, determined by the State value at the top of the branch. You should now have what is show in Fig.10. The last component to add is a delay of 100ms at the end of the main loop (but still inside the loop). This stops the display from updating too quickly. Download the complete flowchart The complete flowchart is too large to print on a page, but you can download the PIC and RedBoard/Uno Flowcode files from the April 2022 page of the PE website. Hardware Setup – PIC16F88 Although the PIC16F88 (like most microcontrollers) can run off its internal oscillator, it does cause some Flowcode complications, so this will be covered in a future article. For now, we’ll stick with the standard external crystal/capacitors oscillator we used in PE, February 2022, p.41 (see Fig.27). We will need the following parts (one each, unless indicated). Assembly Construction is simple – just follow the diagram in Fig.13. Do ensure the supply wires to the microcontroller and the VO connection from the temperature sensor are as short as possible and use the thickest-gauge wire that can plug into the breadboard. Any cable resistance introduced will affect the readings. (Note that if the temperature reading is out because of the leads, there is temperature compensation within the sensor properties.) When built, you should have something like Fig.14. Hardware Setup RedBoard/Uno Building the RedBoard/Uno hardware is just as straightforward – in fact, it’s simpler because there are fewer components – simply follow the diagram in Fig.15. Parts list – RedBoard/Uno circuit LCD 1602 (or 2004) HD44780 chipset LED red LED green LED blue Resistor 330Ω x3 Trimmer 10kΩ Hook-up wire Solderless breadboard Loading the software To test the Flowcode simulation, and then load the software in the PIC or RedBoard, follow the same sequence of operations explained before – see p.40 Fig.12. Layout of the three User Macros. Practical Electronics | April | 2022 53 Fig.13. Circuit diagram of the PIC16F88based temperature display. + 5V 2 for simulation and p.42 for programming the hardware in PE, February 2022. 7 8 Running the circuit 9 10 Once you have programmed your hardware, simply power up and the circuit will start automatically. C3 100nF NC D5 D2 D6 D3 D7 V O 3 Contrast R/ W V SS 5 1 11 12 13 14 4 6 K 16 16x2 L CD (See text ) V R1 1 Fig.14. PIC16F88-based temperature display hardware. 3V 3 D4 D1 E This is a simple circuit, but there’s always room for gremlins! Here are a few tips to getting your circuit running smoothly. 0V If the display is blank, then it could be a contrast issue. The trimmer supplies a voltage to pin 3 of the LCD. The ideal pin 3 voltage for my setup is around 0.5V. If the LCD’s top row is fill with squares, then this is often a sign that the LCD has not being initialised. That could be down to wrong connections or an open circuit. Alternatively, the microcontroller might not be running at the correct speed or has the wrong code installed. A double row of filled squares indicates either the wrong code within the microcontroller, too much contrast or poor connections. If the wrong temperature is displayed, then either the sensor is connected to the wrong pin or the wrong component has been selected in Flowcode and an unexpected voltage level is present on + 5V A D0 RS Basic fault finding + 5V 15 V DD Fig.16. RedBoard/Uno temperature display hardware. NC V O V IN + V S G ND L M35 TO - 92 packa ge (Bottom view) D0/ RX RESET D1/ TX D2 IO REF D3 RedBoard/ Uno IC2 L M35DZ D6 2 D7 V DD A2 D8 A3 D9 SDA/ A4 D10 SCL / A5 D11 11 12 13 14 4 D12 6 D13 G ND NC 0V G ND R2 R1 D3 Red D2 G reen D1 Blue Too h ot Ju st righ t Too cold D5 A1 A0 V O R3 D4 AREF A D4 D0 D5 D1 D6 D2 D7 D3 7 8 9 10 RS E V O G ND NC 15 Contrast 3 R/ W V SS 5 1 K 16 16x2 L CD (See text ) V R1 1 Fig.15. Circuit diagram of the RedBoard/Uno-based temperature display. 54 Practical Electronics | April | 2022 14 6 7 8 9 10 11 12 13 RB0/ INT/ CCP1 V O IC1 PIC16F88 + V D + V S AN0/ RA0 AN1/ RA1 RB1/ SDI/ SDA RB2/ SDO / RX / DT V ref– / CV ref– / AN2/ RA2 RB3/ PG M/ CCP1 C1O UT/ V ref+ / AN3/ RA3 RB4/ SCK / SCL C2O UT/ TO CK I/ AN4/ RA4 RB5/ SS/ TX / CK MCL R/ V pp/ RA5 RB6/ AN5/ PG C/ T1CK I CL K O UT/ O SC2/ RA6 RB7/ AN6/ PG D/ T1O SI CL K IN/ O SC1/ RA7 + V SS 5 G ND L M35 TO - 92 packa ge (Bottom view) 17 18 1 2 3 NC 4 V O IC2 L M35DZ 15 16 X TAL 1 19. 66MH z R3 R2 R1 D3 Red D2 G reen D1 Blue Too h ot Ju st righ t Too cold the microcontroller’s input ADC pin. A performance guide for the LM35 is the output from the sensor is one hundredth of the temperature in Celsius. For example, at 21.3°C the output voltage is approximately 0.213V. Still having problems? If you need help, then create a post at https://flowcode.co.uk/forums/ and someone will help get your project up and running. C2 22pF C1 22pF Martin Whitlo is an Applications Engineer at Matrix TSL – the company behind Flowcode. Try Flowcode for free! We hope you found this article interesting. If you’d like to try Flowcode for free then just go to https ow ode. o.u download and download the code. You’ll get a 30-day free trial of the full version – but that’s not all. Even after the 30 days are up your copy of Flowcode will continue to work, but at a reduced level with a limit on the size of program you can run and access to a more basic set of parts. However, for beginners it is still an ideal platform with which you can build and run programs, on for example, the Arduino Uno/ RedBoard or a PIC 16F88 that we are using in this project. Only when you are sure that you want to use Flowcode do you need to buy inexpensive access to say a Raspberry Pi or Bluetooth module. (See: https ow ode. o.u buy pro ess for all the modules available and what they contain.) What’s more, as soon as you buy any module, the restrictions on the size of your code are removed. If you get stuck with anything relating to Flowcode use (installaio o w re re i ow r compiling to hardware, hardware not working…) then there are forums set up to help you: https:// www. ow ode. o.u oru s dis ount One more thing – Flowcode is deliberately designed to be inexpensive, but PE readers can get a further 20% discount when they use the code PE20 at checkout. Teach-In 8 CD-ROM Exploring the Arduino EE FR -ROM CD ELECTRONICS TEACH-IN 8 FREE CD-ROM SOFTWARE FOR THE TEACH-IN 8 SERIES FROM THE PUBLISHERS OF This CD-ROM version of the exciting and popular Teach-In 8 series has been designed for electronics enthusiasts who want to get to grips with the inexpensive, immensely popular Arduino microcontroller, as well as coding enthusiasts who want to explore hardware and interfacing. Teach-In 8 provides a one-stop source of ideas and practical information. The Arduino offers a remarkably effective platform for developing a huge variety of projects; from operating a set of Christmas tree lights to remotely controlling a robotic vehicle wirelessly or via the Internet. Teach-In 8 is based around a series of practical projects with plenty of information for customisation. The projects can be combined together in many different ways in order to build more complex systems that can be used to solve a wide variety of home automation and environmental monitoring problems. The series includes topics such as RF technology, wireless networking and remote web access. PLUS: PICs and the PICkit 3 – A beginners guide The CD-ROM also includes a bonus – an extra 12-part series based around the popular PIC microcontroller, explaining how to build PIC-based systems. £8.99 INTRODUCING THE ARDUINO • Hardware – learn about components and circuits • Programming – powerful integrated development system • Microcontrollers – understand control operations • Communications – connect to PCs and other Arduinos PLUS... PIC n’MIX PICs and the PICkit 3 - A beginners guide. The why and how to build PIC-based projects Teach In 8 Cover.indd 1 04/04/2017 12:24 PRICE £8.99 Includes P&P to UK if ordered direct from us SOFTWARE The CD-ROM contains the software for both the Teach-In 8 and PICkit 3 series. ORDER YOUR COPY TODAY! JUST CALL 01202 880299 OR VISIT www.epemag.com Practical Electronics | April | 2022 55