Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC16F877A senior design project NEED HELP

Status
Not open for further replies.
do you guys know of any easier way to calculate wind chill, I have a simpler equation WC = Temp - Wind Speed/4, but this is for Celcius and km/hour, so I would need to the the conversions for that. which might be possibly, might but I don't know if I have enough time in the day to do that.

It is clear looking from looking at a windchill chart that that is not a good approximation.

**broken link removed**

The windchill for a 5 mph wind is 4 degrees lower at 40F, 11 degrees lower at 0F and 17 degrees lower at -40F. Also at 0F a 5 mph wind lowers the windchill by 11 degrees, but a 60 mph wind lowers the windchill by 33 degrees, 3 times as much not 12 times as much.

The best way is a 2-d table lookup using temperature and wind speed as indices. Compute the table enties using the formula that you gave earlier:

windchill = 35.74+0.6215T-35.75(V^0.16)+0.4275T(V^0.16)
 
Last edited:
Hey guys, well I know it is isn't a good one for production by any means, but the pressure is on being that I am going to be demonstrating it on friday, and since my teacher gave me the equation i am going to use it. I am interested enough that I will work on it some more after but I figured out how to convert from MPH to KMPH

Thanks for all the input, I will let you know what happens.
 
To go from MPH to kMPH you multiply by 1.6

WC = (Temp+32)*5/9 - 1.6*Wind Speed/4
or,
WC = (Temp+32)*5/9 - Wind Speed*2/5

So, your code would be,

Temp=Temp+32
Temp=Temp+Temp*5
Temp=Temp/9

Speed=Speed*2
Speed=Speed/5

WC=Temp-Speed

Do you need help with the actual code?

Mike.
 
Last edited:
Temp=Temp+32
Temp=Temp+Temp*8 (This is Temp * 9, to multiply by 8 we shift left 3 times)
Temp=Temp/5

Actually the conversion from Celsius to Fahrenheit is:

Temp_F = 9*Temp_C/5 + 32

i.e. you multiply by 9/5 then add 32, not the other way around!

To repeat an old theme, to do these conversions I would use table lookup rather than trying to to do the math. It may be very "old school", but use of retlw is a simple but effective way to look up values.
 
Last edited:
I just occurred to me that the conversion needs to go in the other direction. You have the temperature in Fahrenheit and want it in Celsius to use the formula.

Temp_C = 5*(Temp_F-32)/9.

But rather than working in Fahrenheit at all, why not convert the analog signal directly to Celsius?

Edit: OK you do need to display the temperature in Fahrenheit. Sorry!
 
Last edited:
You are correct, I got the 9 and 5 the wrong way around. I'll edit it.

Mike.
 
You are correct, I got the 9 and 5 the wrong way around. I'll edit it.

I believe that you should subtract 32 not add.

F -> C subtract 32, multiply by 5/9.
C -> F multiply by 9/5, add 32.

Of course, it's the student's responsibility to check, since it's their project and they will be getting the grade.

I was adjunct faculty in a chemical engineering department for several years. The first lecture in the first chemical engineering course taught to sophomores was unit conversions. I really hated to teach the problem session that went with that lecture - an hour and a half of unit conversion problems. How dry!

Anyway, it's a bit disheartening that a senior engineering student is asking for help on unit conversions.

Just my two cents!
 
Bugger, you are right again. I was thinking the freezing point of water was -32°F. It's that long since I worked in such archaic units I got confused.

Mike.
 
You guys are great, I have never been so greatful that my project, would bring so much conversation I am currently debugging this code right now if you want to see it. I am rather proud of it since I am an amature and I was told that May 9th would be tough to get it working by. It is is almost working.

Elizabeth
 

Attachments

  • FixedAtoDwithother4.ASM
    8 KB · Views: 148
my code went from like 130 lines to about 4 hundred with about 2 hours of work, using source code and testing. I think i am finally getting this stuff
 
skyhawk said:
Anyway, it's a bit disheartening that a senior engineering student is asking for help on unit conversions.

Just my two cents!

I am not asking about the actual unit conversions just about coding to go with that sorry I didn't make myself clear for you. But I don't appreciate you assuming that I don't know unit conversions. Yes I am inexperienced in code but I have pretty much carried my whole senior design project.

Elizabeth
 
hi Elizabeth,
Ran your program in simulation.
The Interrupt [ISR] needs to be corrected also the related Interrupt Enables.
After the first ADC read, the program keeps looping in the Call CelConversion routines.?

You are using TMR0 as an Intr.

extract from microchip 16F877A template
NOTE the ISR origin.


;**********************************************************************
Code:
	ORG     0x000             ; processor reset vector

	nop			  ; nop required for icd
  	goto    main              ; go to beginning of program


	ORG     0x004             ; interrupt vector location

	movwf   w_temp            ; save off current W register contents
	movf	STATUS,w          ; move status register into W register
	movwf	status_temp       ; save off contents of STATUS register
	movf	PCLATH,w	  ; move pclath register into w register
	movwf	pclath_temp	  ; save off contents of PCLATH register

; isr code can go here or be located as a call subroutine elsewhere

	movf	pclath_temp,w	  ; retrieve copy of PCLATH register
	movwf	PCLATH		  ; restore pre-isr PCLATH register contents
	movf    status_temp,w     ; retrieve copy of STATUS register
	movwf	STATUS            ; restore pre-isr STATUS register contents
	swapf   w_temp,f
	swapf   w_temp,w          ; restore pre-isr W register contents
	retfie                    ; return from interrupt



main
; remaining code goes here
;---------------------------------------------------------------------------

Do you follow.?:)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top