FPGA Climatic - Project - Page 1
Forum section: electronics / projects

author: skorpyon1992
author_rank: Newbie
timestamp: April 07, 2014, 02:26:22 pm
content: Hello everyone, recently I have started to make a project for Digilent Design Contest 2014. My project is called FPGA Climatic , and the main idea of it is to replace the typical thermostate and the Air Conditioning remote control with only one control device.I have to mention that we are not focusing on the heating and cooling systems , so they will be represented in our project as a light bulb ( heating system ) and a PC fan ( cooling system ).My project idea has been implemented for about 95% percent so far.The components I have used:- Nexys 3 FPGA board;- PmodTMP temperature sensor;- A light bulb , representing the heating system;- A pc fan , representing the cooling system;- 2 Relays ( one for the light bulb , and one for the fan ,also one of them you won't see it because it is glued to the wooden board);- TSOP 4838 IR receiver and a 38KHz remote control;The project is being split in two main parts : the HDL Design ( in Verilog ) and software design ( in ANSI C and ARM Assembly language ).In HDL design I have implemented the following:- I have integrated the ARM Cortex M0 processor in a SoC system with AHB-Lite Peripherals;- The top level of our SoC System was modified to suite our needs ( added interrupts for IR signal , deleted unneeded peripherals);- Custom modules for my input and output peripherals ( ahbinputs and ahb2ctrl );- The VGA module ( vga_console module ) was modified to allow cursor repositioning and screen clearing.- A module for my temperature sensor ( PModTmp ). It is useful to convert and read the temperature from the sensor. This temperature is being read on 12 bits , but we only use 8 of them ( we ommited bit 11 which is the sign bit, and bits 0 , 1 and 2 which are 3 of 4 of the decimal part bits. We will show a positive temperature , with only one decimal : for example 30.0 , 21.5); This temperature is being sent to the SoC system through an 8-bit Bus;- The temperature reading is being refreshed at each second ( I have implemented an autoreset module for this ), so it could be read in real-time;- The IR receiver module; it decodes a received signal from the remote control; we can assign a 3 bit key-code for each key-pressed ( which will be further sent to the AHB System); also for a few pressed buttons ( such as On/OFF , A,B or C ) we will send an interrupt signal to the SoC on another wire;- A PWM fan control module; it receives 6 bit data from the SoC ( values between 111111 and 000000 ), and it generates a correspondent clock signal (111111- 100% Duty Cycle , 100000 - 50% Duty Cycle and so on);- On 2 wires we control the relays for the light bulb and fan;On the software design part I have implemented the thermostat and A/C control parts:- I handled the IR receiver interrupt with Assembly code , I have linked to a INPUT_ISR function; there we will check the key we pressed;- If the on/off key was pressed , then we will see a menu on the screen , and we will have the oportunity to choose heating or cooling mode ;- Otherwise ( if we didn't press the on/off key ) then our system acts as if would be shut down , so we could not choose to control the heating/cooling system;- In cooling/or heating mode, we can choose a desired temperature with left ( decrease temperature ) and right (increase) buttons; to validate our temperature we press the O button, or if we changed our mind , and we don't want to set the thermostate/AC , we can always press the on/off button to exit to the main menu;- If we pressed O button , then it will enter the heating/cooling process; we have 3 states for each mode. I will describe them only for the heating control:* the active state : we will show the current temperature and the setpoint on the screen. It will compare these , and if the current temperature is lower than the setpoint , our heating system will be turned on; otherwise it will go in the pasive state;* the pasive state: it compares ,in the background ,the current temperature with the setpoint and switches to the active mode when the current temperature is lower than the setpoint with about 2 degrees;* the aborted state : even if we are in the active or pasive state, if we press the on/off button , the heating/cooling process will stop and it will return to the main menu;- For the cooling process I have implemented a simple PID controller. It is used to slow down gradually our fan as we approach the current temperature to the setpoint.A youtube link to a small demonstration :If you have any ideas or suggestions, just write back!Thanks!

author: c4757p
author_rank: Super Contributor
timestamp: April 07, 2014, 02:57:45 pm
content: That's a whole lot of logic hardware for a relatively simple task....

author: Dongulus
author_rank: Regular Contributor
timestamp: April 07, 2014, 04:11:40 pm
content: Quote from: c4757p on April 07, 2014, 02:57:45 pmI agree. I understand that the trouble as a student learning FPGAs is trying to find projects where one would fit in. The strength of FPGAs are for applications that require time-sensitive processing or parallel processing, but any processing that can be done sequentially and are not time critical should be done on a microcontroller because they are far cheaper and easier to design with. Having said that, I seem to remember seeing some of past Digilent Design contest finalists that also seemed like they should have been done on microcontrollers instead of FPGAs.I'm familiar with the Nexys 3; I used one for my senior project which was a basic image processor for a video feed. What resolutions and pixel depth are you using for the VGA monitor? My project used 1024x768 images with 8-bit grayscale pixel depth and I had some trouble because the FPGA didn't have enough RAM to store an entire image. I had to offload the image data to the cellular RAM but that was a challenge because I couldn't write data from the image processor output at the same time as I read data to the monitor. Did you encounter any problems like that?

author: skorpyon1992
author_rank: Newbie
timestamp: April 08, 2014, 02:13:04 pm
content: I know that the idea could be easily implemented on an Arduino ( for example ) , but I wanted to create something practical , which could be usable in everyday life. In the same time I wanted to learn new things ( such as HDL design ), different from what we learn at university( that is why I am a beginner in Verilog programming ).Furthermore, I have choosen to work with the FPGA because you can make your own circuits , you can modify or create SoC platforms , integrate processors ( such as ARM Cortex and others), add a lot of peripheral devices. An Arduino Uno , for example , has only 32KB memory and only a few pins. For reading an IR signal ( with IRremote library ) the program itself occupies ~9KB on Arduino. If we want to read the temperature from an analogic sensor ( which is quite easy to do ) , that would occupy another 4,5KB of Arduino's memory. And it would occupy much more than that the controlling part.Speaking about price, FPGA already has integrated Ethernet , VGA , USB , and other small stuff , which for an Arduino you have to buy them separately. And the costs would be almost the same ( depends on what you are doing) .For Dongulus:I did not encountered too much problems with the VGA controller. I have used the AHB VGA module on the SoC system. The image is being displayed on a 1024x768 resolution . This module includes several modules for displaying a custom image , or display characters on the screen . The console part has:* a font_rom module ,where ascii code characters are being "stored" and described in "pixels" , for example ://code x0111'h010: data = 8'b00000000; //11'h011: data = 8'b00000000; //11'h012: data = 8'b01111110; // ******11'h013: data = 8'b10000001; // * *11'h014: data = 8'b10100101; // * * * *11'h015: data = 8'b10000001; // * *11'h016: data = 8'b10000001; // * *11'h017: data = 8'b10111101; // * **** *11'h018: data = 8'b10011001; // * ** *11'h019: data = 8'b10000001; // * *11'h01a: data = 8'b10000001; // * *11'h01b: data = 8'b01111110; // ******11'h01c: data = 8'b00000000; //11'h01d: data = 8'b00000000; //11'h01e: data = 8'b00000000; //11'h01f: data = 8'b00000000; //* and a video ram memory which stores the "console image"The only issue I had was to implement a clear_screen function, in order to redraw a menu. I tried reset somehow the video memory but it didn't work so :* I have choosen an " invisible " character \r ( carriage return );* If we print the character on the screen , it will reposition to 0 the cursor ( code write in the vga_console module )://State Machine for cursor and pixel bufferalways @ (posedge clk, negedge resetn)beginif(!resetn)begincur_x_reg <= 0;cur_y_reg <= 0;endelse if(din==7'b0001101) // if we receive the \r character to printbegincur_x_reg <= 0; // repositioning cursorcur_y_reg <= 0;endelsebegincur_x_reg <= cur_x_next;cur_y_reg <= cur_y_next;pixel_x1 <= pixel_x;pixel_x2 <= pixel_x1;pixel_y1 <= pixel_y;pixel_y2 <= pixel_y1;endend* In my C part I have printed the \r character,then printed a lot of blank characters ( spaces ) on the screen , and reprint the \r character to reposition the cursor.To be more explicit I have filled the screen with empty spaces and repositioned the cursor to the start position.It may be very difficult to understand for ones who didn't work with Cortex M0 and AHB SoC peripherals.I would like some suggestions what to do further on my project idea. Thank you very much!

author: suicidaleggroll
author_rank: Super Contributor
timestamp: April 08, 2014, 03:14:32 pm
content: Quote from: skorpyon1992 on April 08, 2014, 02:13:04 pmThen don't use a bloated Arduino. 9kB for IR and 4.5kB for a temperature sensor is absolutely ridiculous. You could do both of those combined for around 1 kB on any other platform (and likely on an AVR as well, if you leave the Arduino ecosystem).There's no reason the application you described needs any more than a few kB on a microcrontroller, with the exception of VGA (though why you need VGA output on a basic thermostat is lost on me).I recently finished a project with a 38kHz IR receiver, UART output, and 4 GPIO-controlled MOSFET 12v power switches on an MSP430, total firmware size came it at just under 1.1kB. I recently finished another MSP430 project with a UART input, 4 A/D, and 15 GPIO-controlled MOSFET power switches, and a 15-state state machine for logic control (state depends on voltage/temperature inputs from the A/Ds), total firmware size is under 1.8kB. Another MSP430 project I have uses 2 A/D, a UART transmitter, 2 4 MHz SPI Tx/Rx, 16 GPIOs, full on-board PID control logic, and a 128x64 graphic LCD, all for around 12kB (most of that is the graphic LCD library).

author: nosleep
author_rank: Newbie
timestamp: April 08, 2014, 03:41:35 pm
content: Skorpyon, I think your project is well thought-out and implemented. I hope you will show it off once it's 100% ready.Also, I don't think you HAD to use an Arduino or another Microcontroller. The beauty of these projects is that we can implement them however we want isn't it?

author: skorpyon1992
author_rank: Newbie
timestamp: April 08, 2014, 03:58:10 pm
content: Quote from: suicidaleggroll on April 08, 2014, 03:14:32 pmI have given an comparative example only. I am a beginner in microcontrollers and FPGA ( only done some simple projects with PIC , Arduino , and Spartan 6 FPGA ), but I am willing to learn more and more.. But now I need some sugestions and further ideas for my project , that's all

author: AnalysIR
author_rank: Contributor
timestamp: April 23, 2014, 02:37:48 pm
content: Tip: consider using a...TSOP34438 or TSOP4438 IR receiverinstead of the TSOP4838 IR receiverThe TSOP4838 is classed as legacy in the DS & can deliver poor results in some environments, particularly with longer Airconditioner infrared signals.

author: tstanford
author_rank: Newbie
timestamp: April 25, 2014, 04:03:52 am
content: Just in jr college right now, but check out the parallax propeller. Its so easy to do VGA and video with. On a further note, I wish we would have learned at school on something other than just the propeller...