Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC980.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC980A/B Demonstration Board Control
3 
4 LTC2970: Dual I2C Power Supply Monitor and Margining Controller
5 
6 @verbatim
7 http://www.linear.com/product/LTC2970
8 
9 NOTES
10  Setup:
11  Set the terminal baud rate to 115200 and select the newline terminator.
12 
13 @endverbatim
14 
15 http://www.linear.com/product/LTC2970
16 
17 http://www.linear.com/demo/#demoboards
18 
19 
20 Copyright 2018(c) Analog Devices, Inc.
21 
22 All rights reserved.
23 
24 Redistribution and use in source and binary forms, with or without
25 modification, are permitted provided that the following conditions are met:
26  - Redistributions of source code must retain the above copyright
27  notice, this list of conditions and the following disclaimer.
28  - Redistributions in binary form must reproduce the above copyright
29  notice, this list of conditions and the following disclaimer in
30  the documentation and/or other materials provided with the
31  distribution.
32  - Neither the name of Analog Devices, Inc. nor the names of its
33  contributors may be used to endorse or promote products derived
34  from this software without specific prior written permission.
35  - The use of this software may or may not infringe the patent rights
36  of one or more patent holders. This license does not release you
37  from the requirement that you obtain separate licenses from these
38  patent holders to use this software.
39  - Use of the software either in source or binary form, must be run
40  on or directly connected to an Analog Devices Inc. component.
41 
42 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
43 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
44 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
45 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
46 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
47 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
48 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
49 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
50 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
51 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 !*/
53 
54 /*! @file
55  @ingroup LTC2970
56 */
57 
58 #include <Arduino.h>
59 #include <stdint.h>
60 #include "Linduino.h"
61 #include "UserInterface.h"
62 #include "LT_SMBusNoPec.h"
63 #include "LTC2970.h"
64 
65 #define LTC2970_I2C_ADDRESS 0x5B //global 7-bit address
66 //#define LTC2970_I2C_ADDRESS 0x6F //SLAVE_HH 7-bit address
67 
68 
69 /****************************************************************************/
70 // Global variables
71 static uint8_t ltc2970_i2c_address;
72 
74 
79 
80 
81 /****************************************************************************/
82 //! Initialize Linduino
83 //! @return void
84 void setup()
85 {
86  uint16_t return_val;
87 
88  // initialize the i2c port
89  Serial.begin(115200); //! Initialize the serial port to the PC
90  print_title();
91  print_prompt();
92 
94 
95  servo0_value_nom = 0x2733;
96  servo1_value_nom = 0x1A24;
97  servo0_value_marg = 0x2347; // 10% low
98  servo1_value_marg = 0x1786; // 10% low
99 
100  //************************ init_voltage_transition();
101 }
102 
103 //! Main Linduino loop
104 //! @return void
105 void loop()
106 {
107  uint8_t user_command;
108  uint16_t return_val;
109 
110  int i = 0;
111 
112  if (Serial.available()) //! Checks for user input
113  {
114  user_command = read_int(); //! Reads the user command
115  if (user_command != 'm')
116  Serial.println(user_command);
117 
118  switch (user_command) //! Prints the appropriate submenu
119  {
120 
121  case 1 :
122  Serial.print(F("\n****INITIALIZING THE LTC2970****\n"));
124  break;
125 
126  case 2 :
127  Serial.print(F("\n****ENABLE LTC2970 CHANNEL 0 AND CHANNEL 1****\n"));
130 
133  break;
134 
135  case 3 :
136  Serial.print(F("\n****SOFT CONNECT LTC2970 DAC0 and DAC1****\n"));
139  break;
140 
141  case 4 :
142  Serial.print(F("\n****SERVO CHANNEL 0 and 1 VOLTAGES 10% LOW****\n"));
145  break;
146 
147  case 5 :
148  Serial.print(F("\n****SERVO CHANNEL 0 and 1 VOLTAGES TO NOMINAL****\n"));
151  break;
152 
153  case 6 :
154  Serial.print(F("\n****ADC CH_0 VOLTAGE = (HEX VALUE)\n"));
155  return_val = smbus->readWord(ltc2970_i2c_address, LTC2970_CH0_A_ADC);
156  Serial.println(((return_val & 0x7FFF)*500e-6), DEC);
157  Serial.println(return_val, HEX);
158 
159  Serial.print(F("\n****ADC CH_1 VOLTAGE = (HEX VALUE)\n"));
160  return_val = smbus->readWord(ltc2970_i2c_address, LTC2970_CH1_A_ADC);
161  Serial.println(((return_val & 0x7FFF)*500e-6), DEC);
162  Serial.println(return_val, HEX);
163  break;
164 
165  case 7 :
166  Serial.print(F("\n****ADC CH_0 CURRENT = (HEX VALUE)\n"));
167  return_val = smbus->readWord(ltc2970_i2c_address, LTC2970_CH0_B_ADC);
168  Serial.println((((return_val & 0x7FFF)*500e-6)/0.007), DEC);
169  Serial.println(return_val, HEX);
170 
171  Serial.print(F("\n****ADC CH_1 CURRENT = (HEX VALUE)\n"));
172  return_val = smbus->readWord(ltc2970_i2c_address, LTC2970_CH1_B_ADC);
173  Serial.println((((return_val & 0x7FFF)*500e-6)/0.008), DEC);
174  Serial.println(return_val, HEX);
175  break;
176 
177  case 8 :
178  Serial.print(F("\n****PRINT FAULTS, CLEAR LATCHED FAULTS \n"));
180  break;
181 
182  case 9 :
183  Serial.print(F("\n****PRINT DIE TEMPERATURE \n"));
185  break;
186 
187  default:
188  Serial.println(F("Incorrect Option"));
189  break;
190  }
191  print_prompt();
192  }
193 }
194 
195 
196 /************************************************************************/
197 // Function Definitions
198 
199 //! Prints the title block when program first starts.
200 //! @return void
202 {
203  Serial.print(F("\n***************************************************************\n"));
204  Serial.print(F("* DC980 Regulator Control Program *\n"));
205  Serial.print(F("* *\n"));
206  Serial.print(F("* This program provides a simple interface to control the *\n"));
207  Serial.print(F("* the DC980 regulators through the LTC2970 *\n"));
208  Serial.print(F("* *\n"));
209  Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
210  Serial.print(F("* *\n"));
211  Serial.print(F("*****************************************************************\n"));
212 }
213 
214 //! Prints main menu.
215 //! @return void
217 {
218  Serial.print(F("\n"));
219  Serial.print(F(" 1 - Reset the LTC2970, Disable Regulators\n"));
220  Serial.print(F(" 2 - Enable Channel 0 and Channel 1; DACs disconnected\n"));
221  Serial.print(F(" 3 - Soft-Connect DAC0 and DAC1, and Confirm Connection\n"));
222  Serial.print(F(" 4 - Servo Channel 0 and Channel 1 Voltages 10% low\n"));
223  Serial.print(F(" 5 - Servo Channel 0 and Channel 1 Voltages to nominal\n"));
224  Serial.print(F(" 6 - Print Channel 0 & 1 Voltages\n"));
225  Serial.print(F(" 7 - Print Channel 0 & 1 Currents\n"));
226  Serial.print(F(" 8 - Print Fault Register Contents\n"));
227  Serial.print(F(" 9 - Print LTC2970 Temperature\n"));
228  Serial.print(F("\nEnter a command number:"));
229 }
230 
231 
232 //! Writes configuration values to the LTC2970 registers
233 //! @return void
235 {
236  uint16_t return_val;
237  //start the 2970 by configuring all of its registers for this application
238  // use SMbus commands
240  smbus->writeWord(ltc2970_i2c_address, LTC2970_IO, 0x000A);
245  smbus->writeWord(ltc2970_i2c_address, LTC2970_V12_UV, 0x00000);
246 
253 
260 }
261 
static void ltc2970_configure()
Writes configuration values to the LTC2970 registers.
Definition: DC980.ino:234
static uint8_t ltc2970_i2c_address
Definition: DC980.ino:71
unsigned char user_command
#define LTC2970_CH1_A_SERVO
Definition: LTC2970.h:128
static uint16_t servo0_value_marg
Definition: DC980.ino:75
static void loop()
Main Linduino loop.
Definition: DC980.ino:105
void writeWord(uint8_t address, uint8_t command, uint16_t data)
SMBus write word command.
static void print_title()
Prints the title block when program first starts.
Definition: DC980.ino:201
#define LTC2970_CH1_A_OV
Definition: LTC2970.h:126
#define LTC2970_CH1_B_OV
Definition: LTC2970.h:136
#define LTC2970_CH1_A_UV
Definition: LTC2970.h:127
Header File for Linduino Libraries and Demo Code.
#define LTC2970_CH1_B_UV
Definition: LTC2970.h:137
#define LTC2970_CH0_A_SERVO
Definition: LTC2970.h:114
#define LTC2970_V12_OV
Definition: LTC2970.h:106
#define LTC2970_VDD_OV
Definition: LTC2970.h:100
void ltc2970_print_die_temp(LT_SMBus *smbus, uint8_t ltc2970_i2c_address)
Prints die temperature on the LTC2970.
Definition: LTC2970.cpp:265
void ltc2970_read_faults(LT_SMBus *smbus, uint8_t ltc2970_i2c_address)
Read FAULT, FAULT_LA, and FAULT_LA_INDEX registers print the results.
Definition: LTC2970.cpp:289
#define LTC2970_I2C_ADDRESS
Definition: DC980.ino:65
#define LTC2970_CH0_B_ADC
Definition: LTC2970.h:119
static uint16_t servo1_value_marg
Definition: DC980.ino:77
#define LTC2970_ADC_MON
Definition: LTC2970.h:91
#define LTC2970_VDD_UV
Definition: LTC2970.h:101
#define LTC2970_CH0_A_ADC
Definition: LTC2970.h:111
#define LTC2970_CH0_A_OV
Definition: LTC2970.h:112
static LT_SMBusNoPec * smbus
Definition: DC980.ino:73
static uint16_t servo1_value_nom
Definition: DC980.ino:78
void ltc2970_dac_disconnect(LT_SMBus *smbus, uint8_t ltc2970_i2c_address, int dac_number)
Disconnect a DAC from its channel.
Definition: LTC2970.cpp:51
void ltc2970_servo_to_adc_val(LT_SMBus *smbus, uint8_t ltc2970_i2c_address, int channel_number, uint16_t code)
Servo once to a given ADC value.
Definition: LTC2970.cpp:227
#define LTC2970_CH0_A_IDAC
Definition: LTC2970.h:115
LTC SMBus Support: Implementation for a shared SMBus layer.
int32_t read_int()
#define LTC2970_CH0_B_UV
Definition: LTC2970.h:121
#define LTC2970_IO
Definition: LTC2970.h:90
#define LTC2970_CH0_B_OV
Definition: LTC2970.h:120
Header for LTC2970: Dual I2C Power Supply Monitor and Margining Controller.
static void setup()
Initialize Linduino.
Definition: DC980.ino:84
static int i
Definition: DC2430A.ino:184
int ltc2970_soft_connect_dac(LT_SMBus *smbus, uint8_t ltc2970_i2c_address, int dac_number)
soft-connect DACn to its controlled node
Definition: LTC2970.cpp:114
#define LTC2970_CH1_B_ADC
Definition: LTC2970.h:135
#define LTC2970_V12_UV
Definition: LTC2970.h:107
#define LTC2970_CH1_A_IDAC
Definition: LTC2970.h:129
#define LTC2970_CH1_A_ADC
Definition: LTC2970.h:125
#define LTC2970_FAULT_EN
Definition: LTC2970.h:83
void ltc2970_gpio_up(LT_SMBus *smbus, uint8_t ltc2970_i2c_address, int gpio_number)
Set GPIO_n high.
Definition: LTC2970.cpp:5
#define LTC2970_CH0_A_UV
Definition: LTC2970.h:113
static uint16_t servo0_value_nom
Definition: DC980.ino:76
static void print_prompt()
Prints main menu.
Definition: DC980.ino:216
uint16_t readWord(uint8_t address, uint8_t command)
SMBus read word command.