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.

Please could you help me

Status
Not open for further replies.
could you post your updated code please wilksey? i went to see dad today and told him all about you helping! he looked realy pleased (is a bit hard to tell as his face dosnt move properly yet) you must live pretty close to us as we are in devon and thats not far from somerset maybe my dad will buy you a beer when he gets home at the mo he has a anolog scope thats 100mghz thats pretty good (i hope it gives it to me one day) but he wanted a digital one for christmas he was going to get it early this month but got ill before christmas day anyway glad the scope will be good to use yours sounds awsome! how about a pic of it?
 
Hi Logan.

Yes of course I will, hopefully it will attach correctly, you will have to let me know! It is just missing the negative temperature part of the sensing, I was hoping that someone else could have come up with the answer, I have some of these sensors myself now as I got some free samples, so will be looking into them as soon as I get some free time, work is a bit hectic at the moment! Real hardware is better than the emulated stuff!

Yes, I live in Taunton in Somerset, which is not that far from Devon! Driven through Devon many times.

Mine is ok, it is an analog scope, I will take a picture of it, but I will have to dig it out first! lol, haven't needed it in a while!

Tell your dad not to worry and concentrate on getting better! I am sure he is really proud of you for continuing the work whilst he is recovering.

You could always borrow your dads scope instead of getting your own? Sounds like he has quite a decent scope?

Wilksey
 

Attachments

  • DS18X2X MC18 Code (6 Sensors).zip
    79 KB · Views: 123
Hi Logan,

Quick update, I now have the negative code working after some further debugging, I found a bit of spare time this week!

Replace the function in the previous code (inside the ZIP file) in the demowire.c, function name:DS18X2X_get_temp(char *sp) with the following:
Code:
char DS18X2X_get_temp(char *sp)
{
	unsigned char tempC[] = "000.0\r\n";
	unsigned char tempF[] = "000.0\r\n";
	signed int whole = 0, temp = 0;
	signed int LSB = 0;
	signed int frac = 0;
	int CNeg = 0;
	if (sp[1] & 0xF0) { 
		tempC[0] = '-'; 
		// Negative temp values are stored in 2's complement form 
		sp[1] = ~sp[1];
		sp[0] = ~sp[0];
		sp[0] += 1;
		CNeg = 1;
	}
	else tempC[0] = ' ';
	whole = ((sp[1] << 8) + (sp[0] & 0xff) >> 4);
	LSB = sp[0] & 0xF;
	frac = LSB * 625;
	if ((whole/100) && CNeg == 0)
	{	
		tempC[0] = whole/100 + 48;
		temp = (int)(whole / 100) * 100;
		whole -=temp;
	}
	tempC[1] = (whole/10) + 48;
	temp = (int)(whole / 10) * 10;
	whole -= temp;
	tempC[2] = whole + 48;
	tempC[4] = (frac / 1000) + 48;
	PutString(tempC);
}

This will now work, by converting the 2 signed bits to 2's compliment it will calculate the negative values.

Hope this helps!

Wilksey
 
Last edited:
thanks wilksey i am soldering the board up tonight i have had trouble getting it to compile but thats now sorted also i am trying to get usart to work but the baud rate dosnt seem to be right so i am looking at that
many thanks the program is looking awsome!!!!!!!!!!!!!!!!!!!!!!!!!!
logan
 
Hi Logan,

Did you get any joy out of your scope? I posted some pics of mine on the other thread.

The baud rate?

The program I supplied should just compile, unless you have modified to work on your own?

Wilksey
 
hi wilksey the prog did compile in the end it was mplab giving me trouble!!! we got a working scope in the end wich is great your scope looks realy good :D i messed up a chip so got to get another one before i can make this also the ds1820s we had left are all parasite ones so i am waiting for dad to be home tommorow so i can order some more hopefuly mum will let me solder in dads new room so he can watch in bed i will be able to post more once he is home :D thanks again wilksey your a star
logan
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top