Documentation ¶
Overview ¶
Bitscope BSNG API.
This package will expose functionality of the BS10 and BS05 USB oscilloscopes from BitScope, while hiding the the virtual machine inside them.
See https://bitscope.com for more information on these PC oscilloscopes.
Example ¶
bs, err := Open("") if err != nil { log.Fatal(err) } defer bs.Close() bs.Reset() bs.Vertical("2v") bs.Horizontal(1, 40) // 40/1 = 1MHz bs.TriggerTiming(0, 0, 1) bs.Trace(0, 1000, 0) b, _ := bs.Dump(256) println(len(b)) for i := 0; i < len(b); i++ { fmt.Printf("%02x ", b[i]) } println("")
Output:
Index ¶
- type Scope
- func (bs *Scope) Close() error
- func (bs *Scope) Dump(size uint) ([]byte, error)
- func (bs *Scope) Horizontal(pre, div uint) error
- func (bs *Scope) Id() string
- func (bs *Scope) Led(n, i uint)
- func (bs *Scope) Reset()
- func (bs *Scope) Stop()
- func (bs *Scope) Trace(pre, post, delay uint) ([]byte, error)
- func (bs *Scope) TraceTerminate()
- func (bs *Scope) Trigger(src, level uint)
- func (bs *Scope) TriggerLogic(level, mask uint)
- func (bs *Scope) TriggerMode(mod, edge, comp bool)
- func (bs *Scope) TriggerTiming(hoff, hon, timeout uint)
- func (bs *Scope) Vertical(rng string) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scope ¶
type Scope struct { // The ID string returned by the BitScope ID string // The model of the attached scope ('bs10' or 'bs05') Model string // contains filtered or unexported fields }
func Open ¶
Open opens a connection to a BitScope instrument.
If the ID string returned by the BitScope is not recognized as one of the supported ones, an error is returned.
func (*Scope) Dump ¶
Dump reads the data buffer from the BitScope into a byte array. This buffer contains the data acquired during the trace phase.
func (*Scope) Horizontal ¶
Horizontal sets the time base/scale of the trace.
func (*Scope) Id ¶
Id returns a string identifying the VM revision
Use bs.ID instead of this function unless you want a to explicitly ask the BitScope for its ID.
Example ¶
bs, err := Open("") if err != nil { log.Fatal(err) } defer bs.Close() bs.Reset() id := bs.Id() if !strings.HasPrefix(id, "BS00") || len(id) != 8 { log.Fatal("Incorrect ID") } // If the serial channel is not properly configured, a second call to Id() // may return characters from the previous request. id = bs.Id() if !strings.HasPrefix(id, "BS00") || len(id) != 8 { log.Fatal("Incorrect ID") }
Output:
func (*Scope) Led ¶
Led controls the intensity of the 3 LEDs of the BS10, one at a time.
Example ¶
bs, err := Open("") if err != nil { log.Fatal(err) } defer bs.Close() bs.Led('r', 0x10) bs.Led('g', 0x80) bs.Led('y', 0xc0)
Output:
func (*Scope) Trace ¶
Trace starts the data acquisition and waits until it has completed. The parameters pre and post are the pre-trigger and post-trigger number of samples, and the delay is specified in us. The delay is a time window after the trigger in which no samples are recorded.
func (*Scope) TraceTerminate ¶
func (bs *Scope) TraceTerminate()
TraceTerminate is used to 'manually' end the data acquisition, instead of using a trigger event.
func (*Scope) Trigger ¶
Trigger sets the analog trigger to the specified channel and voltage threshold.
func (*Scope) TriggerLogic ¶
TriggerLogic sets the trigger to logic mode with the given bit levels and mask. The mask parameter identifies bits whose state is to be ignored by the trigger comparator.
func (*Scope) TriggerMode ¶
TriggerMode sets the mode (level or edge), edge (0->1 or 1->0), and hardware comparator (active or not).
TODO: invert, swap: ??
func (*Scope) TriggerTiming ¶
TriggerTiming sets the timing parameters associated with a trigger.
For a trigger to be valid, the trigger condition must be false during hold-off, then true during hold-on. Also a timeout can be specified, for the case that the trigger event never happens.
Hold-off time: 0 .. 2^16; tick = 1/Fs Hold-on time: 0 .. 2^16; tick = 1/Fs Timeout: 0 .. 2^16; tick = 6.4 us. 0 = no timeout.