Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] rigol-ds: add DHO800 & DHO900 #229

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contrib/60-libsigrok.rules
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ ATTRS{idVendor}=="1ab1", ATTRS{idProduct}=="0e11", ENV{ID_SIGROK}="1"
# Rigol MSO5000 series
ATTRS{idVendor}=="1ab1", ATTRS{idProduct}=="0515", ENV{ID_SIGROK}="1"

# Rigol DHO800 and DHO900 series
ATTRS{idVendor}=="1ab1", ATTRS{idProduct}=="044c", ENV{ID_SIGROK}="1"
Comment on lines +252 to +253
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lsusb says my DHO804 has a product id of 044d

Bus 003 Device 002: ID 1ab1:044d Rigol Technologies DHO804


# Rohde&Schwarz HMO series mixed-signal oscilloscope (previously branded Hameg) VCP/USBTMC mode
ATTRS{idVendor}=="0aad", ATTRS{idProduct}=="0117", ENV{ID_SIGROK}="1"
ATTRS{idVendor}=="0aad", ATTRS{idProduct}=="0118", ENV{ID_SIGROK}="1"
Expand Down
78 changes: 65 additions & 13 deletions src/hardware/rigol-ds/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static const uint64_t timebases[][2] = {

static const uint64_t vdivs[][2] = {
/* microvolts */
{ 200, 1000000 },
{ 500, 1000000 },
/* millivolts */
{ 1, 1000 },
Expand Down Expand Up @@ -185,6 +186,8 @@ enum series {
DS4000,
MSO5000,
MSO7000A,
DHO800,
DHO900,
};

/* short name, full name */
Expand Down Expand Up @@ -217,6 +220,10 @@ static const struct rigol_ds_series supported_series[] = {
{1000, 1}, {500, 1000000}, 10, 1000, 0},
[MSO7000A] = {VENDOR(AGILENT), "MSO7000A", PROTOCOL_V4, FORMAT_IEEE488_2,
{50, 1}, {2, 1000}, 10, 1000, 8000000},
[DHO800] = {VENDOR(RIGOL), "DHO800", PROTOCOL_V6, FORMAT_IEEE488_2,
{500, 1}, {500, 1000000}, 10, 1000, 10000000},
[DHO900] = {VENDOR(RIGOL), "DHO900", PROTOCOL_V6, FORMAT_IEEE488_2,
{500, 1}, {200, 1000000}, 10, 1000, 10000000},
};

#define SERIES(x) &supported_series[x]
Expand Down Expand Up @@ -291,6 +298,14 @@ static const struct rigol_ds_model supported_models[] = {
{SERIES(MSO5000), "MSO5354", {1, 1000000000}, CH_INFO(4, true), std_cmd},
/* TODO: Digital channels are not yet supported on MSO7000A. */
{SERIES(MSO7000A), "MSO7034A", {2, 1000000000}, CH_INFO(4, false), mso7000a_cmd},
{SERIES(DHO800), "DHO802", {5, 1000000000}, CH_INFO(2, false), std_cmd},
{SERIES(DHO800), "DHO804", {5, 1000000000}, CH_INFO(4, false), std_cmd},
{SERIES(DHO800), "DHO812", {5, 1000000000}, CH_INFO(2, false), std_cmd},
{SERIES(DHO800), "DHO814", {5, 1000000000}, CH_INFO(4, false), std_cmd},
{SERIES(DHO900), "DHO914", {2, 1000000000}, CH_INFO(4, true), std_cmd},
{SERIES(DHO900), "DHO914S", {2, 1000000000}, CH_INFO(4, true), std_cmd},
{SERIES(DHO900), "DHO924", {2, 1000000000}, CH_INFO(4, true), std_cmd},
{SERIES(DHO900), "DHO924S", {2, 1000000000}, CH_INFO(4, true), std_cmd},
};

static struct sr_dev_driver rigol_ds_driver_info;
Expand Down Expand Up @@ -913,20 +928,43 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
some_digital = TRUE;
/* Turn on LA module if currently off. */
if (!devc->la_enabled) {
if (rigol_ds_config_set(sdi, protocol >= PROTOCOL_V3 ?
":LA:STAT ON" : ":LA:DISP ON") != SR_OK)
switch (protocol) {
case PROTOCOL_V1:
case PROTOCOL_V2:
cmd = ":LA:DISP ON";
break;
case PROTOCOL_V3:
case PROTOCOL_V4:
case PROTOCOL_V5:
cmd = ":LA:STAT ON";
break;
case PROTOCOL_V6:
cmd = ":LA:ENAB ON";
break;
}
if (rigol_ds_config_set(sdi, cmd) != SR_OK)
return SR_ERR;
devc->la_enabled = TRUE;
}
}
if (ch->enabled != devc->digital_channels[ch->index]) {
/* Enabled channel is currently disabled, or vice versa. */
if (protocol >= PROTOCOL_V5)
cmd = ":LA:DISP D%d,%s";
else if (protocol >= PROTOCOL_V3)
cmd = ":LA:DIG%d:DISP %s";
else
switch (protocol) {
case PROTOCOL_V1:
case PROTOCOL_V2:
cmd = ":DIG%d:TURN %s";
break;
case PROTOCOL_V3:
case PROTOCOL_V4:
cmd = ":LA:DIG%d:DISP %s";
break;
case PROTOCOL_V5:
cmd = ":LA:DISP D%d,%s";
break;
case PROTOCOL_V6:
cmd = ":LA:DIG:ENAB %";
break;
}

if (rigol_ds_config_set(sdi, cmd, ch->index,
ch->enabled ? "ON" : "OFF") != SR_OK)
Expand All @@ -940,11 +978,24 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
return SR_ERR;

/* Turn off LA module if on and no digital channels selected. */
if (devc->la_enabled && !some_digital)
if (rigol_ds_config_set(sdi,
devc->model->series->protocol >= PROTOCOL_V3 ?
":LA:STAT OFF" : ":LA:DISP OFF") != SR_OK)
if (devc->la_enabled && !some_digital) {
switch (protocol) {
case PROTOCOL_V1:
case PROTOCOL_V2:
cmd = ":LA:DISP OFF";
break;
case PROTOCOL_V3:
case PROTOCOL_V4:
case PROTOCOL_V5:
cmd = ":LA:STAT OFF";
break;
case PROTOCOL_V6:
cmd = ":LA:ENAB OFF";
break;
}
if (rigol_ds_config_set(sdi, cmd) != SR_OK)
return SR_ERR;
}

/* Set memory mode. */
if (devc->data_source == DATA_SOURCE_SEGMENTED) {
Expand All @@ -970,6 +1021,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
break;
}
case PROTOCOL_V5:
case PROTOCOL_V6:
/* The frame limit has to be read on the fly, just set up
* reading of the first frame */
if (rigol_ds_config_set(sdi, "REC:CURR 1") != SR_OK)
Expand All @@ -984,7 +1036,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
devc->analog_frame_size = analog_frame_size(sdi);
devc->digital_frame_size = digital_frame_size(sdi);

switch (devc->model->series->protocol) {
switch (protocol) {
case PROTOCOL_V2:
if (rigol_ds_config_set(sdi, ":ACQ:MEMD LONG") != SR_OK)
return SR_ERR;
Expand Down Expand Up @@ -1021,7 +1073,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
(devc->timebase * devc->model->series->num_horizontal_divs);
} else {
float xinc;
if (devc->model->series->protocol < PROTOCOL_V3) {
if (protocol < PROTOCOL_V3) {
sr_err("Cannot get samplerate (below V3).");
return SR_ERR;
}
Expand Down
43 changes: 33 additions & 10 deletions src/hardware/rigol-ds/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ SR_PRIV int rigol_ds_capture_start(const struct sr_dev_inst *sdi)
case PROTOCOL_V3:
case PROTOCOL_V4:
case PROTOCOL_V5:
case PROTOCOL_V6:
if (first_frame && rigol_ds_config_set(sdi, ":WAV:FORM BYTE") != SR_OK)
return SR_ERR;
if (devc->data_source == DATA_SOURCE_LIVE) {
Expand Down Expand Up @@ -499,6 +500,7 @@ SR_PRIV int rigol_ds_channel_start(const struct sr_dev_inst *sdi)
break;
case PROTOCOL_V4:
case PROTOCOL_V5:
case PROTOCOL_V6:
if (ch->type == SR_CHANNEL_ANALOG) {
if (rigol_ds_config_set(sdi, ":WAV:SOUR CHAN%d",
ch->index + 1) != SR_OK)
Expand Down Expand Up @@ -828,7 +830,7 @@ SR_PRIV int rigol_ds_receive(int fd, int revents, void *cb_data)
* next frame and read it back instead.
*/
if (devc->data_source == DATA_SOURCE_SEGMENTED &&
devc->model->series->protocol == PROTOCOL_V5) {
devc->model->series->protocol >= PROTOCOL_V5) {
int frames = 0;
if (rigol_ds_config_set(sdi, "REC:CURR %d", devc->num_frames + 1) != SR_OK)
return SR_ERR;
Expand Down Expand Up @@ -882,20 +884,41 @@ SR_PRIV int rigol_ds_get_dev_cfg(const struct sr_dev_inst *sdi)

/* Digital channel state. */
if (devc->model->has_digital) {
if (sr_scpi_get_bool(sdi->conn,
devc->model->series->protocol >= PROTOCOL_V3 ?
":LA:STAT?" : ":LA:DISP?",
&devc->la_enabled) != SR_OK)
switch (devc->model->series->protocol) {
case PROTOCOL_V1:
case PROTOCOL_V2:
cmd = ":LA:DISP?";
break;
case PROTOCOL_V3:
case PROTOCOL_V4:
case PROTOCOL_V5:
cmd = ":LA:STAT?";
break;
case PROTOCOL_V6:
cmd = ":LA:ENAB?";
break;
}
if (sr_scpi_get_bool(sdi->conn, cmd, &devc->la_enabled) != SR_OK)
return SR_ERR;
sr_dbg("Logic analyzer %s, current digital channel state:",
devc->la_enabled ? "enabled" : "disabled");
for (i = 0; i < ARRAY_SIZE(devc->digital_channels); i++) {
if (devc->model->series->protocol >= PROTOCOL_V5)
cmd = g_strdup_printf(":LA:DISP? D%d", i);
else if (devc->model->series->protocol >= PROTOCOL_V3)
cmd = g_strdup_printf(":LA:DIG%d:DISP?", i);
else
switch (devc->model->series->protocol) {
case PROTOCOL_V1:
case PROTOCOL_V2:
cmd = g_strdup_printf(":DIG%d:TURN?", i);
break;
case PROTOCOL_V3:
case PROTOCOL_V4:
cmd = g_strdup_printf(":LA:DIG%d:DISP?", i);
break;
case PROTOCOL_V5:
cmd = g_strdup_printf(":LA:DISP? D%d", i);
break;
case PROTOCOL_V6:
cmd = g_strdup_printf(":LA:DIG:ENAB? D%d", i);
break;
}
res = sr_scpi_get_bool(sdi->conn, cmd, &devc->digital_channels[i]);
g_free(cmd);
if (res != SR_OK)
Expand Down
1 change: 1 addition & 0 deletions src/hardware/rigol-ds/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum protocol_version {
PROTOCOL_V3, /* DS2000, DSO1000 */
PROTOCOL_V4, /* DS1000Z */
PROTOCOL_V5, /* MSO5000 */
PROTOCOL_V6, /* DHO800, DHO900 */
};

enum data_format {
Expand Down