Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
DC1989A.ino
Go to the documentation of this file.
1 /*!
2 Linear Technology DC1989A Demonstration Board
3 LTM4676: Dual Output PolyPhase Step-Down DC/DC Module with Digital Power System Management
4 
5 @verbatim
6 
7 NOTES
8  Setup:
9  Set the terminal baud rate to 115200 and select the newline terminator.
10 
11 @endverbatim
12 
13 http://www.linear.com/product/LTM4676
14 http://www.linear.com/demo/DC1989A
15 
16 
17 Copyright 2018(c) Analog Devices, Inc.
18 
19 All rights reserved.
20 
21 Redistribution and use in source and binary forms, with or without
22 modification, are permitted provided that the following conditions are met:
23  - Redistributions of source code must retain the above copyright
24  notice, this list of conditions and the following disclaimer.
25  - Redistributions in binary form must reproduce the above copyright
26  notice, this list of conditions and the following disclaimer in
27  the documentation and/or other materials provided with the
28  distribution.
29  - Neither the name of Analog Devices, Inc. nor the names of its
30  contributors may be used to endorse or promote products derived
31  from this software without specific prior written permission.
32  - The use of this software may or may not infringe the patent rights
33  of one or more patent holders. This license does not release you
34  from the requirement that you obtain separate licenses from these
35  patent holders to use this software.
36  - Use of the software either in source or binary form, must be run
37  on or directly connected to an Analog Devices Inc. component.
38 
39 THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
40 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
41 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42 IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
43 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44 LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
45 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
46 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
48 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49 */
50 
51 #include <Arduino.h>
52 #include <Linduino.h>
53 #include <UserInterface.h>
54 #include <stdint.h>
55 
56 #include <LT_Wire.h>
57 //#include <LT_twi.h>
58 #include <LT_SMBusPec.h>
59 #include <LT_PMBusMath.h>
60 #include <LT_SMBus.h>
61 #include <LT_PMBusRail.h>
62 #include <LT_I2CBus.h>
63 #include <LT_SMBusGroup.h>
64 #include <LT_PMBusDetect.h>
65 #include <LT_PMBus.h>
66 #include <LT_FaultLog.h>
67 #include <LT_PMBusDevice.h>
68 #include <LT_SMBusNoPec.h>
69 #include <LT_SMBusBase.h>
70 #include <LT_PMBusDetect.h>
71 #include <LT_PMBusSpeedTest.h>
72 #include <LT_PMBusDeviceLTC3880.h>
73 #include <LT_3880FaultLog.h> // For compilation of library
74 
75 #define LTM4676_I2C_ADDRESS_0 0x45
76 #define LTM4676_I2C_ADDRESS_1 0x46
77 #define LTM4676_I2C_ADDRESS_2 0x47
78 #define LTM4676_I2C_ADDRESS_3 0x48
79 #define LTM4676_I2C_ADDRESS_R 0x31
80 
81 // Global variables
82 static uint8_t ltm4676_i2c_address_0;
83 static uint8_t ltm4676_i2c_address_1;
84 static uint8_t ltm4676_i2c_address_2;
85 static uint8_t ltm4676_i2c_address_3;
86 static uint8_t ltm4676_i2c_address_r;
87 static uint8_t pages[2];
88 
89 static LT_SMBus *smbus = new LT_SMBusPec();
90 static LT_PMBus *pmbus = new LT_PMBus(smbus);
91 static LT_PMBusDetect *detector = new LT_PMBusDetect(pmbus);
93 
94 //! Initialize Linduino
95 void setup()
96 {
97  Serial.begin(115200); //! Initialize the serial port to the PC
98  print_title();
104 
105  detector->detect();
106  rail = detector->getRails()[0];
107 
108  print_prompt();
109 }
110 
111 //! Repeats Linduino loop
112 void loop()
113 {
114  uint8_t user_command;
115  uint8_t res;
116  uint8_t model[7];
117  uint8_t *addresses = NULL;
118 
119  if (Serial.available()) //! Checks for user input
120  {
121  user_command = read_int(); //! Reads the user command
122  if (user_command != 'm')
123  Serial.println(user_command);
124 
125  switch (user_command) //! Prints the appropriate submenu
126  {
127  case 1:
128  menu_1_basic_commands(); // Print single-ended voltage menu
129  break;
130  case 2:
131  pmbus->readModel(ltm4676_i2c_address_0, model);
132  Serial.print(F("MODEL "));
133  Serial.print((char *)model);
134  Serial.println();
135  break;
136  case 3:
138  Serial.println(res, HEX);
139  break;
140  case 4:
142  delete rail;
143  delete smbus;
144  delete pmbus;
145  delete detector;
146  smbus = new LT_SMBusPec();
147  pmbus = new LT_PMBus(smbus);
148  detector = new LT_PMBusDetect(pmbus);
149  detector->detect();
150  rail =detector->getRails()[0];
151  break;
152  case 5:
154  delete rail;
155  delete smbus;
156  delete pmbus;
157  delete detector;
158  smbus = new LT_SMBusNoPec();
159  pmbus = new LT_PMBus(smbus);
160  detector = new LT_PMBusDetect(pmbus);
161  detector->detect();
162  rail = detector->getRails()[0];
163  break;
164  case 6:
165  addresses = smbus->probe(0);
166  while (*addresses != 0)
167  {
168  Serial.print(F("ADDR 0x"));
169  Serial.println(*addresses++, HEX);
170  }
171  break;
172  case 7 :
173  pmbus->resetGlobal();
174  break;
175  default:
176  Serial.println(F("Incorrect Option"));
177  break;
178  }
179  print_prompt();
180  }
181 
182 }
183 
184 // Function Definitions
185 
186 //! Prints the title block when program first starts.
188 {
189  Serial.print(F("\n*****************************************************************\n"));
190  Serial.print(F("* DC1590B Demonstration Program *\n"));
191  Serial.print(F("* *\n"));
192  Serial.print(F("* This program demonstrates how to send and receive data from *\n"));
193  Serial.print(F("* the DC1590B demo board. *\n"));
194  Serial.print(F("* *\n"));
195  Serial.print(F("* Set the baud rate to 115200 and select the newline terminator.*\n"));
196  Serial.print(F("* *\n"));
197  Serial.print(F("*****************************************************************\n"));
198 }
199 
200 //! Prints main menu.
202 {
203  Serial.print(F("\n 1-Basic Commands\n"));
204  Serial.print(F(" 2-Model Number\n"));
205  Serial.print(F(" 3-Revision Number\n"));
206  Serial.print(F(" 4-PEC On\n"));
207  Serial.print(F(" 5-PEC Off\n"));
208  Serial.print(F(" 6-Bus Probe\n"));
209  Serial.print(F(" 7-Reset\n"));
210  Serial.print(F("\nEnter a command:"));
211 }
212 
213 //! Prints a warning if the demo board is not detected.
215 {
216  Serial.println(F("\nWarning: Demo board not detected. Linduino will attempt to proceed."));
217 }
218 
220 {
221  uint8_t user_command;
222  float result;
223  uint16_t status;
224 
225  do
226  {
227  //! Displays the Read/Write menu
228  Serial.print(F("\nRead/Write\n\n"));
229  Serial.print(F(" 1-Read Voltages\n"));
230  Serial.print(F(" 2-Read Currents\n"));
231  Serial.print(F(" 3-Read Power\n"));
232  Serial.print(F(" 4-Read Status\n"));
233  Serial.print(F(" 5-Sequence Off/On\n"));
234  Serial.print(F(" 6-Margin High\n"));
235  Serial.print(F(" 7-Margin Low\n"));
236  Serial.print(F(" 8-Margin Off\n"));
237  Serial.print(F(" 9-Clear Faults\n"));
238  Serial.print(F(" m-Main Menu\n"));
239  Serial.print(F("\nEnter a command: "));
240 
241  user_command = read_int(); //! Reads the user command
242  if (user_command == 'm') // Print m if it is entered
243  {
244  Serial.print(F("m\n"));
245  }
246  else
247  Serial.println(user_command); // Print user command
248 
249  switch (user_command)
250  {
251  case 1:
252  result = rail->readVin(false);
253  Serial.print(F("LTM4676 VIN "));
254  Serial.println(result, DEC);
255  result = rail->readVout(false);
256  Serial.print(F("LTM4676 VOUT "));
257  Serial.println(result, DEC);
258  break;
259  case 2:
260  result = rail->readIin(false);
261  Serial.print(F("LTM4676 IIN "));
262  Serial.println(result, DEC);
263  result = rail->readIout(false);
264  Serial.print(F("LTM4676 IOUT "));
265  Serial.println(result, DEC);
266  break;
267  case 3:
268  result = rail->readPout(false);
269  Serial.print(F("LTM4676 POUT "));
270  Serial.println(result, DEC);
271  break;
272  case 4:
273  status = rail->readStatusWord();
274  Serial.print(F("LTM4676 STATUS WORD 0x"));
275  Serial.println(status, HEX);
276  break;
277  case 5:
278  rail->sequenceOff();
279  delay (2000);
280  rail->sequenceOn();
281  break;
282  case 6:
283  rail->marginHigh();
284  break;
285  case 7:
286  rail->marginLow();
287  break;
288  case 8:
289  rail->marginOff();
290  break;
291  case 9:
292  rail->clearFaults();
293  break;
294  default:
295  if (user_command != 'm')
296  Serial.println(F("Invalid Selection"));
297  break;
298  }
299  }
300  while (user_command != 'm');
301 }
302 
303 
static uint8_t ltm4676_i2c_address_1
Definition: DC1989A.ino:83
LT_PMBusRail ** getRails()
LTC PSM Device.
unsigned char user_command
LTC SMBus Support: API for a shared SMBus layer.
void sequenceOn()
Sequence on a polyphase rail.
LTC SMBus Support: Implementation for a shared SMBus layer.
LTC SMBus Support: Implementation for a shared SMBus layer.
String status(void)
Returns a descriptive string based on status of pins.
Definition: DC2364A.ino:217
float readIin(bool polling)
Read the input current of a polyphase rail.
Header File for Linduino Libraries and Demo Code.
void enablePec(uint8_t address)
Enable pec for all transactions.
Definition: LT_PMBus.cpp:3173
void readModel(uint8_t address, uint8_t *model)
Get the model.
Definition: LT_PMBus.cpp:2409
void disablePec(uint8_t address)
Disable pec for all transactions.
Definition: LT_PMBus.cpp:3210
LTC PMBus Support.
static uint8_t pages[2]
Definition: DC1989A.ino:87
uint8_t readPmbusRevision(uint8_t address)
Get the pmbus revision.
Definition: LT_PMBus.cpp:2380
static LT_SMBus * smbus
Definition: DC1989A.ino:89
TwoWire.h - TWI/I2C library for Arduino & Wiring Copyright (c) 2006 Nicholas Zambetti.
#define LTM4676_I2C_ADDRESS_2
Definition: DC1989A.ino:77
static LT_PMBusRail * rail
Definition: DC1989A.ino:92
LTC SMBus Support: Implementation for a LTC3880 Fault Log.
static uint8_t ltm4676_i2c_address_2
Definition: DC1989A.ino:84
static void print_warning_prompt()
Prints a warning if the demo board is not detected.
Definition: DC1989A.ino:214
#define LTM4676_I2C_ADDRESS_3
Definition: DC1989A.ino:78
void marginHigh()
Margin high polyphase rail.
LT_I2CBus: Routines to communicate to I2C by Wire Library.
LTC PMBus Support: Implementation for a LTC Fault Log.
void clearFaults()
Clear faults of polyphase rail.
void resetGlobal(void)
Issue reset to all devices.
Definition: LT_PMBus.cpp:2906
void sequenceOff()
Sequence off a polyphase rail.
uint16_t readStatusWord()
Read the status word of a polyphase rail.
static uint8_t ltm4676_i2c_address_3
Definition: DC1989A.ino:85
static LT_PMBus * pmbus
Definition: DC1989A.ino:90
virtual uint8_t * probe(uint8_t command)=0
SMBus bus probe.
static uint8_t ltm4676_i2c_address_r
Definition: DC1989A.ino:86
LTC PSM Device Dector.
LTC SMBus Support: Implementation for a shared SMBus layer.
void marginOff()
Margin off polyphase rail.
float readVin(bool polling)
Read the input voltage of a polyphase rail.
int32_t read_int()
Library Header File for LT_PMBusDevice.
static LT_PMBusDetect * detector
Definition: DC1989A.ino:91
#define LTM4676_I2C_ADDRESS_0
Linear Technology DC1989A Demonstration Board LTM4676: Dual Output PolyPhase Step-Down DC/DC Module w...
Definition: DC1989A.ino:75
LTC PMBus Support.
float readPout(bool polling)
Read the output power of a polyphase rail.
LTC PSM SpeedTest.
static void print_title()
Prints the title block when program first starts.
Definition: DC1989A.ino:187
void detect()
Detect devices on bus.
static void menu_1_basic_commands()
Definition: DC1989A.ino:219
static void loop()
Repeats Linduino loop.
Definition: DC1989A.ino:112
static void setup()
Initialize Linduino.
Definition: DC1989A.ino:95
#define LTM4676_I2C_ADDRESS_1
Definition: DC1989A.ino:76
static uint8_t ltm4676_i2c_address_0
Definition: DC1989A.ino:82
void marginLow()
Margin low polyphase rail.
float readIout(bool polling)
Read the output current of a polyphase rail.
LTC PMBus Support: Math conversion routines.
PMBusRail communication. For Multiphase Rails.
Definition: LT_PMBusRail.h:72
float readVout(bool polling)
Read the output voltage of a polyphase rail.
static void print_prompt()
Prints main menu.
Definition: DC1989A.ino:201
LTC SMBus Support: Implementation for a shared SMBus layer.
#define LTM4676_I2C_ADDRESS_R
Definition: DC1989A.ino:79
PMBus communication.
Definition: LT_PMBus.h:370