I just got one of these for a good price on ebay & found a little bit of time to start playing with it... though since I'm not a Windows person, it's a little harder :/ sadly probably not going to get much time in the next several weeks to do anything decent with this, so figured I'd share the little bit i've been able to get to (apologies for the really crappy code; just dumping this in case someone wants to play with it)
So far I'm able to set the digital outputs... (testing from OSX). Don't think it'll be too hard to get the other functionality done.
Example setting O3, O5 high:
$ python
Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Hantek_3X25 import *
>>> d = DDS()
>>>
>>> c = Config()
>>> c.CounterMode = True
>>> c.ProgrammableOutput = True
>>> c.DigitalPins = 0x22
>>> d.configure(c)
Requires pyusb.
based on example in pyusb tutorial at
http://pyusb.sourceforge.net/docs/1.0/tutorial.htmlusing SigRok documentation @
http://sigrok.org/wiki/Hantek_DDS-3X25 as basis for USB comms.
Hantek_3X25.py:
#!/usr/bin/env python
import usb.core
import usb.util
import struct
Falling = 0
Rising = 1
class Config(object):
ResetExtTrigger = False
ExtTrigger = False
ExtTriggerEdge = Falling
ContinuousOutput = False
ResetCounter = False
CounterMode = False
ProgrammableOutput = False
DigitalPins = 0x0000
ClockDivider = 1
class DDS(object):
def __init__(self, idVendor=0x0483, idProduct=0x5721):
# find our device
dev = usb.core.find(idVendor=idVendor, idProduct=idProduct)
# was it found?
if dev is None:
raise ValueError('Device not found')
# set the active configuration. With no arguments, the first
# configuration will be the active one
dev.set_configuration()
# get an endpoint instance
cfg = dev.get_active_configuration()
interface_number = cfg[(0,0)].bInterfaceNumber
alternate_setting = usb.control.get_interface(dev, interface_number)
intf = usb.util.find_descriptor( \
cfg, bInterfaceNumber = interface_number, \
bAlternateSetting = alternate_setting \
)
self.out_ep = usb.util.find_descriptor(
intf,
# match the first OUT endpoint
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_OUT
)
assert self.out_ep is not None
self.in_ep = usb.util.find_descriptor(
intf,
# match the first IN endpoint
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_IN
)
assert self.in_ep is not None
def configure(self, config):
b0 = 0x00
b1 = 0x00
b2 = config.DigitalPins & 0xff
b3 = (config.DigitalPins >> 8) & 0x0f
b4 = config.ClockDivider
b5 = 0
if config.ResetExtTrigger:
b0 |= 0x20
if config.ExtTrigger:
b0 |= 0x10
if config.ExtTriggerEdge:
b0 |= 0x08
if config.ContinuousOutput:
b0 |= 0x04
if config.ResetCounter:
b0 |= 0x02
if config.CounterMode:
b0 |= 0x01
if config.ProgrammableOutput:
b1 = 0x01
cval = struct.pack('>BBBBBBB', 0xa0, b0, b1, b2, b3, b4, b5)
self.out_ep.write(cval)