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 CCS Technical Support

ex_ad12.c

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest_Me
Guest







ex_ad12.c
PostPosted: Wed Oct 20, 2004 3:23 am     Reply with quote

Code:
/////////////////////////////////////////////////////////////////////////
////                          EX_AD12.C                              ////
////                                                                 ////
////  This program will read two A/D channels and display the        ////
////  results as both a voltage and raw hex number over the RS-232.  ////
////  A reading is taken every second. This can be done using either ////
////  the LTC1298 chip or the MCP3208 chip.                          ////
////                                                                 ////
////  Configure the CCS prototype card as follows:                   ////
////                                                                 ////
////     Using the LTC1298:                                          ////
////     LTC1298    Protoboard                                       ////
////         1           50  B3                                      ////
////         2            9  analog-1                                ////
////         3           10  analog-2                                ////
////         4           27  gnd                                     ////
////         5           49  B2                                      ////
////         6           48  B1                                      ////
////         7           47  B0                                      ////
////         8           28  +5V                                     ////
////                                                                 ////
////     Using the MCP3208:                                          ////
////     MCP3208    Protoboard                                       ////
////         1            9  analog-1                                ////
////         2           10  analog-2                                ////
////         3..8        Not Connected                               ////
////         9           27  gnd                                     ////
////        10           50  B3                                      ////
////        11           49  B2                                      ////
////        12           48  B1                                      ////
////        13           47  B0                                      ////
////        14           27  gnd                                     ////
////        15           28  +5V                                     ////
////        16           28  +5V                                     ////
////                                                                 ////
////     See additional connections below.                           ////
////                                                                 ////
////  Using the MCP3208 requires changing the #include <LTC1298.C>   ////
////  to #include <MCP3208.C>                                        ////
////                                                                 ////
////  This example will work with the PCB, PCM and PCH compilers.    ////
////  The following conditional compilation lines are used to        ////
////  include a valid device for each compiler.  Change the device,  ////
////  clock and RS232 pins for your hardware if needed.              ////
/////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996,2003 Custom Computer Services         ////
//// This source code may only be used by licensed users of the CCS  ////
//// C compiler.  This source code may only be distributed to other  ////
//// licensed users of the CCS C compiler.  No other use,            ////
//// reproduction or distribution is permitted without written       ////
//// permission.  Derivative programs created using this software    ////
//// in object code form are not restricted in any way.              ////
/////////////////////////////////////////////////////////////////////////


#if defined(__PCB__)
#include <16c56.h>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A3, rcv=PIN_A2)  // Jumpers: 11 to 17, 12 to 18

#elif defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12
#endif

#include <ltc1298.c>


void display_data( long int data ) {
     char volt_string[6];

     convert_to_volts( data, volt_string );
     printf(volt_string);
     printf(" (%4lX)",data);
}


void main() {
   long int value;

   adc_init();

   printf("Sampling:\r\n");

   do {
      delay_ms(1000);

      value = read_analog(0);
      printf("\n\rCh0: ");
      display_data( value );

      value = read_analog(1);
      printf("   Ch1: ");
      display_data( value );

   } while (TRUE);

}


hey guys, this is an example from CCS. this makes it able to use an extern 12-Bit ADC. my question is, can i use this code for 16f628 also?

regards,
guest_me
dvsoft



Joined: 28 Nov 2003
Posts: 46

View user's profile Send private message

PostPosted: Wed Oct 20, 2004 5:48 am     Reply with quote

bonjour,

Yes you can
but you must set the correct pin for the extern ADC
in file ltc1298.c
Code:

#ifndef ADC_CS

#define ADC_CLK  PIN_B0
#define ADC_DOUT PIN_B1
#define ADC_DIN  PIN_B2
#define ADC_CS   PIN_B3

#endif


ANd selecte the correct pin for the UART

Alain
Guest








PostPosted: Wed Oct 20, 2004 7:25 am     Reply with quote

dvsoft wrote:
bonjour,

Yes you can
but you must set the correct pin for the extern ADC
in file ltc1298.c
Code:

#ifndef ADC_CS

#define ADC_CLK  PIN_B0
#define ADC_DOUT PIN_B1
#define ADC_DIN  PIN_B2
#define ADC_CS   PIN_B3

#endif


ok thanks, but do really need the CS pin? or DIN?

ANd selecte the correct pin for the UART

Alain
Guest








PostPosted: Wed Oct 20, 2004 7:33 am     Reply with quote

dvsoft wrote:
bonjour,

Yes you can
but you must set the correct pin for the extern ADC
in file ltc1298.c
Code:

#ifndef ADC_CS

#define ADC_CLK  PIN_B0
#define ADC_DOUT PIN_B1
#define ADC_DIN  PIN_B2
#define ADC_CS   PIN_B3

#endif



ANd selecte the correct pin for the UART

Alain



ok thanks, but do really need the CS pin? or DIN?
Guest








PostPosted: Wed Oct 20, 2004 7:39 am     Reply with quote

and what signal should i connect with the RX and TX pins?
DOUT of ltc1298 --> RX of PIC16f628?

hmm im so confused.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Wed Oct 20, 2004 9:09 am     Reply with quote

The Rx & Tx are for RS232 data. The example program prints the data to a terminal. If you plan on hooking up the PIC to a PC to look at the data, then you will need a RS232 chip and connect it to the PIC.

Quote:
but do really need the CS pin? or DIN?

DIN - Yes, it is for writing data to the device such as for selecting then channel
CS - is chip select. You can probably just tie the CS of the ltc1298 low and enable it all the time. I would check the datasheet just to make sure that by selecting it that it doesn't do something like stop doing convesions.
Guest








PostPosted: Wed Oct 20, 2004 2:37 pm     Reply with quote

Mark wrote:
The Rx & Tx are for RS232 data. The example program prints the data to a terminal. If you plan on hooking up the PIC to a PC to look at the data, then you will need a RS232 chip and connect it to the PIC.

Quote:
but do really need the CS pin? or DIN?

DIN - Yes, it is for writing data to the device such as for selecting then channel
CS - is chip select. You can probably just tie the CS of the ltc1298 low and enable it all the time. I would check the datasheet just to make sure that by selecting it that it doesn't do something like stop doing convesions.


k thanks,
but i cant still imagine what i need the DIN pin for.
bonjour?
Guest







bonjour?
PostPosted: Wed Oct 20, 2004 2:48 pm     Reply with quote

What's this bonjour crap? Shocked
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Wed Oct 20, 2004 5:20 pm     Reply with quote

Quote:
but i cant still imagine what i need the DIN pin for.

Uh, data in? Did ya look at the driver file at all? See where they use the DIN to setup to read values back.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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