Twokinds ARCHIVE Forums

This forum is for the preservation of old threads from before the forum pruning.
It is currently Tue Apr 15, 2025 5:19 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: PCR temperature control device built using PIC assembly
PostPosted: Fri Aug 29, 2008 2:47 am 
Offline
Council Member
User avatar

Joined: Fri Dec 08, 2006 2:06 am
Posts: 544
Location: Behind my computer.
So, today was the last day of Summer Quarter at school. I just finished the second and final project in my Electronics cource - Building a PCR temperature cycler.

My device uses a PIC16F684 microcontroller, running This assembly code, assembled using the MPASM Suite via the MPLAB IDE ver. 8.14.

Schematic of the device is as follows(image may come later):
On the PIC:
Vcc - power
Vss - ground

A.0 - MCP9701 output
A.1 - Connected to two things: One, to the data/instruction select pin of the LCD, and two to a voltage divider. The divider I used had a 10k resistor between the pin and ground, and a 100k trim-pot variable resistor between power and the pin. This allows for adjusting of the voltage reference for the A.0 analog input. 2.5V is what the divided voltage is supposed to be.
A.2 - Enable pin on the LCD
A.3 - Switch 1 - GO/NEXT button
A.4 - Output to one side of the H-bridge
A.5 - Output to the other side of the H-bridge

C.0 - D0 on LCD
C.1 - D1 on LCD
C.2 - D2 on LCD
C.3 - D3 on LCD
C.4 - Switch 2 - UP button
C.5 - Switch 3 - DOWN button

Note that all three switches use normally-open push-button switches between the pin and power, and a 10k pull-down resistor between the pin and ground.

------------------------------------------------------------------------------------------------
My device uses a 20X4 LCD and three push-button switches for user interaction, a MCP9701 temperature sensor for temperature feedback, and two pins connected to an H-bridge(either relay or semiconductor based) for output to a peltier junction.

Operation:
When you first power the device up, it will show a custom startup message, and after 5 seconds, go to a screen where you can set the first time variable. It it called 'melting' time, because that is what the correct teminology for the first temperature is, or so I was told. You can adjust this up and down by 1 between 0 and 255(where it rolls over), using the up and down buttons. The next button saves the value and goes to the next screen.

Next you have a temperature-set screen. You can set the temperature anywhere between 0 and 102C in 0.125, or 1/8th of a degree increments. Again, up and down increase and decrease the value, and next goes to the next screen.

You have two more sets of time/temperature screens, and then you have a 'cycles' screen. This tells the device how many times to cycle between each of the three temperatures before shutting off. This value can be set between 0 and 255(0 will actually do 256 times).

Now, when you press the next button, you will be taken to a screen where you can review all three temperatures and times. Pressing up or down from this screen goes back to the start of the settings process, and pressing next starts the process.


The process:
When you start the process, it will compare the temperature you set to the temperature from the A2D converter, and if the incoming temperature is too high, it will turn on the peltier in 'cool' mode, or if it is too low, it will turn it on in 'heat' mode.
When the two temperatures are equal, it will start counting down, still holding the temperature as close as it can to the set temperature.

When the counter reaches 0, it will reset things and repeat the process for the second temperature, and then again for the third and final temperature.

When the third and final temperature is done, it will decrement the number of cycles left to do, and repeat the entire process.

Note that the counter is done in one-second increments, and during the temperature controlling process the LCD updates 5 times a second.


Hopefully *someone* understood *some* of this.


-RobbieThe1st


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2008 11:26 am 
Offline
The Inkwell Coyote
User avatar

Joined: Wed Aug 09, 2006 4:28 pm
Posts: 7495
Location: 44°39'54"N 90°10'33"W
Your post made me dizzy...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2008 3:04 pm 
Offline
Templar GrandMaster
User avatar

Joined: Thu Dec 15, 2005 6:28 pm
Posts: 661
Location: praying to the porcelain god
i did something similar with a BS2 micro controller a while back. i had one of those anique window unit air conditioners so i hooked up a stepper motor to the switch ect and had the BS2 determin the temp in the room if above A the air comes on if below A the air goes back off. worked nicely.


( sorry i am WAY to lazy to go into as much detail as you rob)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2008 3:19 pm 
Offline
Templar Inner Circle
User avatar

Joined: Wed Jan 17, 2007 12:33 pm
Posts: 2879
Location: Nebraska, USA
My PIC assembly's too rusty for me to decipher it without more time than I'm able to spare (when I used a PIC, I took the lazy way out and wrote the code in C). Out of curiosity, why did the requirements state three different temperatures?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 30, 2008 12:27 am 
Offline
Council Member
User avatar

Joined: Fri Dec 08, 2006 2:06 am
Posts: 544
Location: Behind my computer.
avwolf wrote:
My PIC assembly's too rusty for me to decipher it without more time than I'm able to spare (when I used a PIC, I took the lazy way out and wrote the code in C). Out of curiosity, why did the requirements state three different temperatures?

Well, according to This page, three are needed, however the temperatures are different than the 'default' ones I got.

Still, the way I have it set up, *any* temperature/time combination can be added.

BTW, I never learned C myself, so I couldn't do that... However, I would be willing to bet my code is more efficient than if I had tried to do it using C.


epion04, that is a good idea - I would have simply pulled the AC's switch out and used a couple of relays to turn it on or off however.

Also, having done a little bit of Basic, and used a BS2 myself, I can say that this little PIC16f684 I used is *far* faster(Duh!), and learning Assembly was fairly easy - It looks like Basic, but the instructions are simpler. Plus, the class I was in taught using Assembly, so trying to use something else wouldn't have been right.


-RobbieThe1st


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 30, 2008 12:43 am 
Offline
Templar GrandMaster
User avatar

Joined: Thu Dec 15, 2005 6:28 pm
Posts: 661
Location: praying to the porcelain god
yeah my set up was rather rudimentary, a 10 min project out of boredom mainly, just an a2d converter a thermal resistor and a quick program that mimicked an analogue window comparator.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 03, 2008 1:32 pm 
Offline
Templar Inner Circle
User avatar

Joined: Wed Jan 17, 2007 12:33 pm
Posts: 2879
Location: Nebraska, USA
RobbieThe1st wrote:
avwolf wrote:
My PIC assembly's too rusty for me to decipher it without more time than I'm able to spare (when I used a PIC, I took the lazy way out and wrote the code in C). Out of curiosity, why did the requirements state three different temperatures?

Well, according to This page, three are needed, however the temperatures are different than the 'default' ones I got.

Ah... I wasn't familiar with PCR, so that explains it. Thank you.

RobbieThe1st wrote:
BTW, I never learned C myself, so I couldn't do that... However, I would be willing to bet my code is more efficient than if I had tried to do it using C.[...]Also, having done a little bit of Basic, and used a BS2 myself, I can say that this little PIC16f684 I used is *far* faster(Duh!), and learning Assembly was fairly easy - It looks like Basic, but the instructions are simpler. Plus, the class I was in taught using Assembly, so trying to use something else wouldn't have been right.

Oh, certainly fair enough. And yes, it'd probably be quicker on its feet than C (it's why, even to this day, certain bits of graphics and physics engines get written in assembly). I never really learned PIC assembly -- we did x86 and AVR assembly in my classes. The PIC was for my thesis project, so our restrictions were looser. C's something worth learning though: more embedded devices get programmed in C than in their individual assembly languages because the trade-off in operational speed is generally outweighed by the ease of portability and general improvements to maintainability offered by C. I used MPLAB for mine too, so I know it'll let a C compiler plug in. All my jabbering aside, I'm glad you did it in assembly -- you learn a lot more about the underlying hardware that way; it's an appreciation that people who only use high-level languages don't ever gain. And you learn some fun tricks. ;)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group