Skip to content

Commit f82666d

Browse files
committed
docs: Upate f2209/f2210 usage code.
1 parent 92a33b4 commit f82666d

File tree

2 files changed

+64
-49
lines changed

2 files changed

+64
-49
lines changed

docs/product/f2209/quickstart.mdx

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,23 @@ Let's get started with the FoBE Quill ESP32S3 Mesh using the MFP interface.
101101
#include <Wire.h>
102102

103103
// GP8303 I2C Address and Registers
104-
#define GP8303_ADDR 0x58
104+
#define GP8303_ADDR 0x58
105105
#define REG_DAC_DATA 0x02 // DAC data register
106106

107107
#define IIC_SDA_PIN PIN_MFP3
108108
#define IIC_SCL_PIN PIN_MFP4
109109

110+
bool setDACCurrent(uint8_t address, uint16_t cur_levl) {
111+
uint8_t hibyte = ((cur_levl << 4) & 0xff00) >> 8;
112+
uint8_t lobyte = ((cur_levl << 4) & 0xff);
113+
cur_levl = lobyte << 8 | hibyte;
114+
Wire.beginTransmission(address);
115+
Wire.write((uint8_t)REG_DAC_DATA);
116+
Wire.write((uint8_t)(cur_levl >> 8));
117+
Wire.write((uint8_t)(cur_levl & 0xFF));
118+
return (Wire.endTransmission() == 0);
119+
}
120+
110121
void setup() {
111122
Serial.begin(115200);
112123

@@ -115,20 +126,17 @@ void setup() {
115126

116127
Wire.begin(IIC_SDA_PIN, IIC_SCL_PIN);
117128

118-
// Calculate DAC value for 16mA (4-20mA range)
119-
uint16_t dacValue = (uint16_t)((16.0 - 4.0) * 4095.0 / 16.0);
120-
dacValue = dacValue << 4; // Left shift 4 bits for 12-bit DAC
121-
122-
// Write DAC data to register 0x02
123129
Wire.beginTransmission(GP8303_ADDR);
124-
Wire.write(REG_DAC_DATA);
125-
Wire.write(dacValue & 0xFF); // Low byte
126-
Wire.write((dacValue >> 8) & 0xFF);// High byte
127-
Wire.endTransmission();
128-
129-
Serial.print("DAC value set to: ");
130-
Serial.print(dacValue >> 4);
131-
Serial.println(" (16mA)");
130+
if (Wire.endTransmission() == 0) {
131+
Serial.println("GP8303 DAC found.");
132+
} else {
133+
Serial.println("GP8303 DAC not found. Check connections.");
134+
while (1) delay(1000);
135+
}
136+
137+
// set output current of 0-20ma(0-4095)
138+
setDACCurrent(GP8303_ADDR, 1024);
139+
Serial.println("DAC current set to 1024 (approx. 5mA).");
132140
}
133141

134142
void loop() {
@@ -153,7 +161,8 @@ monitor_raw = true
153161
4. Build and upload the project. You should measure 16mA output on the output terminal.
154162
155163
```bash
156-
DAC value set to: 3072 (16mA)
164+
GP8303 DAC found.
165+
DAC current set to 1024 (approx. 5mA).
157166
```
158167
159168
:::note

docs/product/f2210/quickstart.mdx

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,27 @@ Let's get started with the FoBE Quill ESP32S3 Mesh using the MFP interface.
101101
#include <Wire.h>
102102

103103
#define GP8403_ADDR 0x58
104-
#define GP8403_MODE_005V 0x00
105-
#define GP8403_MODE_005_010V 0x01
106-
#define GP8403_MODE_010_005V 0x10
107-
#define GP8403_MODE_010V 0x11
108-
#define GP8403_MODE_ADDRESS 0x01
104+
#define GP8403_MODE_005V 0x00 // 0-5V output
105+
#define GP8403_MODE_005_010V 0x10 // 0-5V and 0-10V output
106+
#define GP8403_MODE_010_005V 0x01 // 0-10V and 0-5V output
107+
#define GP8403_MODE_010V 0x11 // 0-10V output
109108

109+
#define GP8403_MODE_ADDRESS 0x01
110110
#define GP8403_CHANNEL0_ADDRESS 0x02 // Channel 0 data register
111111
#define GP8403_CHANNEL1_ADDRESS 0x04 // Channel 1 data register
112112

113113
#define IIC_SDA_PIN PIN_MFP3
114114
#define IIC_SCL_PIN PIN_MFP4
115115

116-
void setDACVoltage(uint16_t voltage, uint8_t channel) {
117-
voltage &= 0x0FFF; // Ensure 12-bit data
118-
Wire.beginTransmission(GP8403_ADDR);
119-
Wire.write(channel == 0 ? GP8403_CHANNEL0_ADDRESS : GP8403_CHANNEL1_ADDRESS);
120-
Wire.write(voltage & 0xFF); // Low 8 bits
121-
Wire.write((voltage >> 8) & 0xFF); // High 8 bits
122-
Wire.endTransmission();
116+
bool setDACVoltage(uint8_t address, uint16_t vol_levl, uint8_t channel_reg) {
117+
uint8_t hibyte = ((vol_levl << 4) & 0xff00) >> 8;
118+
uint8_t lobyte = ((vol_levl << 4) & 0xff);
119+
vol_levl = lobyte << 8 | hibyte;
120+
Wire.beginTransmission(address);
121+
Wire.write((uint8_t)channel_reg);
122+
Wire.write((uint8_t)(vol_levl >> 8));
123+
Wire.write((uint8_t)(vol_levl & 0xFF));
124+
return (Wire.endTransmission() == 0);
123125
}
124126

125127
void setup() {
@@ -131,25 +133,28 @@ void setup() {
131133
Wire.begin(IIC_SDA_PIN, IIC_SCL_PIN);
132134

133135
Wire.beginTransmission(GP8403_ADDR);
134-
Wire.write(GP8403_MODE_ADDRESS);
135-
Wire.write(GP8403_MODE_010V); // Set 0-10V range for both channels
136-
Wire.endTransmission();
137-
138-
// Set channel 0 to output 3V (in 0-10V range)
139-
uint16_t dacValue0 = (3 * 4095) / 10; // 3V in 0-10V range
140-
setDACVoltage(dacValue0, 0);
141-
142-
// Set channel 1 to output 8V (in 0-10V range)
143-
uint16_t dacValue1 = (8 * 4095) / 10; // 8V in 0-10V range
144-
setDACVoltage(dacValue1, 1);
145-
146-
Serial.println("DAC configuration completed:");
147-
Serial.print("Channel 0: 3V (DAC value: ");
148-
Serial.print(dacValue0);
149-
Serial.println(")");
150-
Serial.print("Channel 1: 8V (DAC value: ");
151-
Serial.print(dacValue1);
152-
Serial.println(")");
136+
if (Wire.endTransmission() == 0) {
137+
Serial.println("GP8403 DAC found.");
138+
} else {
139+
Serial.println("GP8403 DAC not found. Check connections.");
140+
while (1) delay(1000);
141+
}
142+
143+
Wire.beginTransmission(GP8403_ADDR);
144+
Wire.write((uint8_t)GP8403_MODE_ADDRESS);
145+
Wire.write((uint8_t)GP8403_MODE_005_010V);
146+
if(Wire.endTransmission() == 0){
147+
Serial.println("GP8403 mode set to 0-5V and 0-10V output.");
148+
} else {
149+
Serial.println("Failed to set GP8403 mode.");
150+
while (1) delay(1000);
151+
}
152+
153+
setDACVoltage(GP8403_ADDR, 2047, GP8403_CHANNEL0_ADDRESS);
154+
Serial.println("Channel 0 set to approximately 2.5V.");
155+
156+
setDACVoltage(GP8403_ADDR, 2047, GP8403_CHANNEL1_ADDRESS);
157+
Serial.println("Channel 1 set to approximately 5V.");
153158
}
154159

155160
void loop() {
@@ -174,9 +179,10 @@ monitor_raw = true
174179
4. Build and upload the project. You should measure 3V on channel 0 and 8V on channel 1 using a multimeter.
175180
176181
```bash
177-
DAC configuration completed:
178-
Channel 0: 3V (DAC value: 1228)
179-
Channel 1: 8V (DAC value: 3276)
182+
GP8403 DAC found.
183+
GP8403 mode set to 0-5V and 0-10V output.
184+
Channel 0 set to approximately 2.5V.
185+
Channel 1 set to approximately 5V.
180186
```
181187
182188
:::note

0 commit comments

Comments
 (0)