mirror of https://github.com/EspoTek/Labrador.git
PSU outputs in
This commit is contained in:
parent
8ebd95e928
commit
97adf23b3d
|
@ -2,6 +2,7 @@ clear all
|
|||
clc
|
||||
|
||||
__addpaths;
|
||||
__load_globals;
|
||||
|
||||
[usb_handle, usb_context] = mex_usb_init("03eb", "ba94");
|
||||
if(isequal(usb_handle, "0000000000000000"))
|
||||
|
@ -13,10 +14,15 @@ fprintf("\nTurning on the digital outputs...\n");
|
|||
fflush(stdout);
|
||||
labrador_set_digital_outputs(usb_handle, usb_context, 1,1,1,1);
|
||||
|
||||
pause(2)
|
||||
fprintf("\nTurning off the digital outputs...\n");
|
||||
|
||||
fprintf("\nSetting PSU to 8.8V...\n");
|
||||
fflush(stdout);
|
||||
labrador_set_digital_outputs(usb_handle, usb_context, 0,0,0,0);
|
||||
labrador_set_psu_voltage(usb_handle, usb_context, 8.8);
|
||||
|
||||
%pause(2)
|
||||
%fprintf("\nTurning off the digital outputs...\n");
|
||||
%fflush(stdout);
|
||||
%labrador_set_digital_outputs(usb_handle, usb_context, 0,0,0,0);
|
||||
|
||||
|
||||
fprintf("\nExiting Libusb...\n");
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
fprintf("Loading the global variables...\n");
|
||||
global vcc
|
||||
vcc = 3.3
|
||||
global vref
|
||||
vref = vcc/2
|
||||
global R4
|
||||
R4 = 75000
|
||||
global R3
|
||||
R3 = 1000000
|
||||
global R2
|
||||
R2 = 1000
|
||||
global R1
|
||||
R1 = 1000
|
||||
global PSU_ADC_TOP
|
||||
PSU_ADC_TOP = 128
|
||||
global FGEN_OFFSET
|
||||
FGEN_OFFSET = 5
|
||||
global FGEN_LIMIT
|
||||
FGEN_LIMIT = 3.2
|
||||
global CLOCK_FREQ
|
||||
CLOCK_FREQ = 48000000
|
||||
global DAC_SPS
|
||||
DAC_SPS = 1000000
|
||||
global ADC_SPS
|
||||
ADC_SPS = 750000
|
||||
global ADC_SPF #samples per frame
|
||||
ADC_SPF = (ADC_SPS/1000)
|
||||
|
||||
fprintf("\n")
|
|
@ -1,5 +1,4 @@
|
|||
function [] = labrador_set_digital_outputs(usb_handle, usb_context, port0, port1, port2, port3);
|
||||
%labrador_set_digital_outputs(usb_handle, usb_context, 1,1,1,1);
|
||||
digital_state = uint16(0);
|
||||
|
||||
if(port0 ~= 0) digital_state = digital_state + 1; end
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
function [] = labrador_set_psu_voltage(usb_handle, usb_context, voltage);
|
||||
|
||||
global vref;
|
||||
global PSU_ADC_TOP;
|
||||
|
||||
vinp = voltage/11;
|
||||
vinn = 0;
|
||||
|
||||
psu_duty_cycle = uint16(((vinp - vinn)/vref * PSU_ADC_TOP));
|
||||
|
||||
if ((psu_duty_cycle>106) || (psu_duty_cycle<21))
|
||||
error_message = sprintf("PSU DUTY CYCLE of value %d OUT OF RANGE!\nDid you try and set the voltage below 4.5 or above 12?\nAborting...\n", psu_duty_cycle);
|
||||
error(error_message);
|
||||
end
|
||||
mex_usb_send_control(usb_handle, usb_context, '40', 'a3', dec2hex(psu_duty_cycle), '0', '0', []);
|
Binary file not shown.
Loading…
Reference in New Issue