CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

max6675
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Dec 09, 2017 6:39 am     Reply with quote

You have to 'split up' your program and send data to a PC terminal program.

You need to be able to see
1) the raw data from TC device
2) the result of the sortout() function
3) the result of the toCalcTC() function
When you do this ,you'll be able to see the result of each operation you're asking the PIC to do, Right now there is no way to see if the TC device is actually returning the correct data or if one of the 'math' functions is really causing the problem. Often 'casting' or 'math' will cause problems.

If you can't send to PC, then instead of reading the TC device, use a known number as the data and see what happens. For test purposes I'd try 5 values that cover the range of the TC device.IE if the range was from 0 to 100, I'd use 0, 25,50,80,100. Now if the LED display shows the correct result for the values you use as being 'TC device data', then you know the 'math' functions are correct. Therefore the bad data must be the TC device data. If that's the case you could have 1) incorrect wiring, 2) wrong SPI mode( it's 0 according to earlier posts) 3 defective chip 4) bad sensor or something else.

While the 3 digit LED display is fine for the final product, for 'debug' purpose you really need to send the data to a PC, an LCD module or even 16 LEDs.

Also, I'd put the 'LED display code' inside a 'function', like you did the 'math' routines. Since it does work it will make the main() code simpler to look at. something like void dspLED_TC_data(int16 result). I like names that say what they do, easier for me.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sat Dec 09, 2017 7:14 am     Reply with quote

Quote:

it is there i forget to copy the line here is the code.


That is not confidence giving,
How a single line inside the code gets omitted is not easy to see.

Build a _small_ program that just accesses the device. Preferably just using serial to send the result to the PC. It should be something _complete_. As Temtronic says you need to do one thing at a time.
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Sat Dec 09, 2017 9:49 am     Reply with quote

Er.

According to the picture of the module, it has the pins as GND, VCC, CLX, CS, DATA.

You post:
16f72 max6675 module

14 3
16 5
17 4
vcc 2
gnd 1

Now pin 14 is C3, 16 is C5, and 17 is C6. Disagrees totally with the pins you are using in the setup. No wonder it doesn't work.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 09, 2017 10:04 am     Reply with quote

Ttelmah, I get his connections as follows and it looks OK to me.
Code:
16f72      max6675   #use spi()

14 RC3     3 sck     CLK=PIN_C3 
16 RC5     5 so      DI=PIN_C5
17 RC6     4 cs      ENABLE=PIN_C6
vcc        2 vcc
gnd        1 gnd
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Dec 09, 2017 1:34 pm     Reply with quote

madhusuthanan wrote:
hi Ttelmah,

it is there i forget to copy the line here is the code.

But that's not really your code, because it doesn't compile. If I copy and
paste your code into MPLAB and compile, it gives me these errors:
Quote:
*** Error 97 "pcm_test.c" Line 10(5,112): Must have a #USE DELAY before this #USE
*** Error 12 "pcm_test.c" Line 39(18,23): Undefined identifier SPI_1
2 Errors, 0 Warnings.
Build Failed.

To fix those errors, I have to move the #use delay() statement above
the #use spi() line. Also, I have to rename the Stream in #use spi()
to SPI_1. Then it compiles.

So you're not really testing the same code that you post. Or you're not
testing it at all.
madhusuthanan



Joined: 23 Aug 2017
Posts: 15

View user's profile Send private message Send e-mail

max6675
PostPosted: Sat Jan 13, 2018 11:21 am     Reply with quote

I find the solution for that issue not it is showing the correct value. I made manually get the value of the module with software spi communication. manually calculated from spi communication. thanks for guidance for finding the issue.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
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
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group