141 Serial.begin(115200);
145 if (demo_board_connected)
155 uint8_t acknowledge = 0;
156 if (Serial.available())
159 if (user_command !=
'm')
160 Serial.println(user_command);
162 switch (user_command)
177 Serial.println(F(
"Incorrect Option"));
180 Serial.println(F(
"***** I2C ERROR *****"));
197 Serial.print(
"\nDac Code = 0x");
198 Serial.print(dac_code, HEX);
199 Serial.print(
"\nOutput voltage = ");
200 Serial.print(voltage, 3);
208 float voltage_high, voltage_low;
209 uint16_t code_high, code_low;
212 Serial.print(
"\nEnter voltage_high: ");
213 while (!Serial.available());
215 Serial.print(voltage_high);
216 Serial.println(
" V");
218 Serial.print(
"Enter voltage_low: ");
219 while (!Serial.available());
221 Serial.print(voltage_low);
222 Serial.println(
" V");
228 Serial.print(F(
"Enter any character to stop. "));
229 while (!Serial.available())
243 Serial.print(F(
"\nEnter the reference voltage: "));
246 Serial.print(F(
" V"));
253 Serial.print(
"\nEnter your choice (1 - Unipolar, 2 - Bipolar): ");
255 Serial.print(choice);
260 Serial.print(F(
"\nSet jumpers JP3 and JP4 to UNI."));
265 Serial.print(F(
"\nSet jumpers JP3 and JP4 to BIP."));
266 Serial.print(F(
"\nIn bipolar mode, set JP6 and JP7 to EXT and apply an appropriate supply"));
267 Serial.print(F(
"\nto AMP V+, AMP V–, and GND turret posts."));
275 Serial.print(F(
"\nType 1 to enter voltage, 2 to enter code:"));
278 Serial.println(user_input);
291 Serial.print(F(
"Enter Desired DAC output voltage: "));
293 Serial.print(dac_voltage, 3);
294 Serial.println(
" V");
303 Serial.println(
"Enter Desired DAC Code");
304 Serial.print(
"(Format 32768, 0x8000, 0100000, or B1000000000000000): ");
307 Serial.println(returncode, HEX);
316 Serial.print(F(
"\n*****************************************************************\n"));
317 Serial.print(F(
"* DC1096B Demonstration Program *\n"));
318 Serial.print(F(
"* *\n"));
319 Serial.print(F(
"* This program demonstrates how to send data to the 16-bit DAC. *\n"));
320 Serial.print(F(
"* Set the baud rate to 115200 and select the newline terminator.*\n"));
321 Serial.print(F(
"* *\n"));
322 Serial.print(F(
"*****************************************************************\n"));
328 Serial.print(F(
"\n*****************************************************************\n"));
329 Serial.print(F(
"\nSelected Range: "));
331 Serial.print(F(
"Unipolar"));
333 Serial.print(F(
"Bipolar"));
334 Serial.print(F(
"\nSelected Reference Voltage: "));
336 Serial.print(F(
" V"));
338 Serial.print(F(
"\n\nMenu:"));
339 Serial.print(F(
"\n 1 - Set output\n"));
340 Serial.print(F(
" 2 - Square Wave output\n"));
341 Serial.print(F(
" 3 - Set Reference Voltage\n"));
342 Serial.print(F(
" 4 - Select Unipolar/Bipolar\n"));
343 Serial.print(F(
"Enter a command: "));
static uint8_t menu1_voltage_output()
Function to enter a digital value and get the analog output.
static void menu4_select_range()
Select between unipolar/bipolar.
static uint16_t get_voltage()
Get voltage from user input, calculate DAC code based on lsb, offset.
unsigned char user_command
static void print_prompt()
Prints main menu.
static int16_t prompt_voltage_or_code()
Prompt user to enter a voltage or digital code to send to DAC.
#define output_high(pin)
Set "pin" high.
Header File for Linduino Libraries and Demo Code.
static float reference_voltage
static void print_title()
Prints the title block when program first starts.
static void setup()
Initialize Linduino.
static uint16_t get_code()
Get code to send to DAC directly, in decimal, hex, or binary.
static uint8_t menu2_square_wave_output()
Function to generate a square wave of desired frequency and voltage ranges.
uint16_t LTC2642_voltage_to_code(float voltage, float reference_voltage, uint8_t range)
Calculates the 16 bit data code from voltage.
static void menu3_change_reference_voltage()
Function to change the reference voltage to be used.
#define LTC2642_CS
Define the SPI CS pin.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
static void loop()
Repeats Linduino loop.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
float LTC2642_code_to_voltage(uint16_t code, float reference_voltage, uint8_t range)
Calculates the output voltage from the given digital code and reference voltage.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
LTC2642: 16-/14-/12-Bit VOUT DAC with SPI Interface LTC2641: 16-/14-/12-Bit VOUT DAC with SPI Interfa...
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
#define QUIKEVAL_CS
QuikEval CS pin (SPI chip select on QuikEval connector pin 6) connects to Arduino SS pin...
void LTC2642_write(uint8_t cs, uint16_t data)
Writes the 16-bit data into the DAC.
static uint8_t demo_board_connected
Set to 1 if the board is connected.