-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support RHS2116 streaming and stimulation #67
Changes from 1 commit
b19f6a0
5a136d6
fcf921a
50e29db
33d933d
ea49ff5
cbb9f70
39ee5bc
5818b57
e60f898
35d1862
191bedb
6eb907a
75c12ef
7a7bd95
4eb85eb
4ac8aa4
9769985
a266c31
879c318
1138ee2
517e7dd
4dd39bb
a07d1bb
58c41a7
f42fb50
bd54594
20f779e
8b7852d
74585bc
da99155
a30d975
7ddea06
3d6fb57
68552df
c946cb1
4bfe9c0
181bf0f
9fb74da
56396ac
a1be2ef
8b2b93a
65546e3
bf5ebe9
01c4e38
c100fe6
2df0ff0
f2db16f
de1d561
b5d8720
d9066e0
8aa7eed
63bbc4f
2b70a4c
649ac2d
9ca6531
96c64b7
d628246
9b78802
571b8b2
ac28b93
4097251
7b4c7de
7574e63
c809023
ad55181
6216f5e
80dcdb9
a5e0505
6dc9e26
c123dd5
391ad2b
56e026c
7bdb036
fb191f0
ff250e9
4088fd6
7ef2536
01e3661
589370e
cf1557f
e8add7f
2b1039b
dcbc0c5
25010e4
a38c23f
259cd20
9347ce3
744d587
fcca30a
be731ce
bd979f5
ba63945
66f858b
2bb4474
e44531d
e7a63cb
cf4ce2f
5dc8fb8
9215835
7e2c852
0b071bf
7a3a6c2
7cb45a2
18b50bf
de8af86
beb4610
b86733c
62aa90b
e2b7f72
ee8a775
cf48a92
3cbf6ca
13fb905
7ac700f
01b36a2
4209da7
84ec7ed
51fb1fb
6e8133e
208d631
068c681
07871b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file (along with a few others in the same OpenEphys.Onix/OpenEphys.Onix folder path) are leftovers from the old folder pattern. These should be removed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,12 +31,12 @@ public ConfigureHeadstageRhs2116() | |
[TypeConverter(typeof(HubDeviceConverter))] | ||
public ConfigureRhs2116Trigger StimulusTrigger { get; set; } = new(); | ||
|
||
internal override void UpdateDeviceNames(string hubName) | ||
internal override void UpdateDeviceNames() | ||
{ | ||
LinkController.DeviceName = $"{hubName}/{nameof(LinkController)}"; | ||
Rhs2116A.DeviceName = $"{hubName}/{nameof(Rhs2116A)}"; | ||
Rhs2116B.DeviceName = $"{hubName}/{nameof(Rhs2116B)}"; | ||
StimulusTrigger.DeviceName = $"{hubName}/{nameof(StimulusTrigger)}"; | ||
LinkController.DeviceName = GetFullDeviceName(nameof(LinkController)); | ||
Rhs2116A.DeviceName = GetFullDeviceName(nameof(Rhs2116A)); | ||
Rhs2116B.DeviceName = GetFullDeviceName(nameof(Rhs2116B)); | ||
StimulusTrigger.DeviceName = GetFullDeviceName(nameof(StimulusTrigger)); | ||
} | ||
|
||
public PortName Port | ||
|
@@ -53,6 +53,16 @@ public PortName Port | |
} | ||
} | ||
|
||
|
||
[Description("If defined, it will override automated voltage discovery and apply the specified voltage" + | ||
"to the headstage. Warning: this device requires 3.4V to 4.4V for proper operation." + | ||
"Supplying higher voltages may result in damage to the headstage.")] | ||
public double? PortVoltage | ||
{ | ||
get => LinkController.PortVoltage; | ||
set => LinkController.PortVoltage = value; | ||
} | ||
|
||
internal override IEnumerable<IDeviceConfiguration> GetDevices() | ||
{ | ||
yield return LinkController; | ||
|
@@ -65,40 +75,38 @@ class ConfigureHeadstageRhs2116LinkController : ConfigureFmcLinkController | |
{ | ||
protected override bool ConfigurePortVoltage(DeviceContext device) | ||
{ | ||
const uint MinVoltage = 33; | ||
const uint MaxVoltage = 50; | ||
const uint VoltageOffset = 25; | ||
const uint VoltageIncrement = 02; | ||
const double MinVoltage = 3.3; | ||
const double MaxVoltage = 4.4; | ||
const double VoltageOffset = 2.0; | ||
const double VoltageIncrement = 0.2; | ||
|
||
for (uint voltage = MinVoltage; voltage <= MaxVoltage; voltage += VoltageIncrement) | ||
for (var voltage = MinVoltage; voltage <= MaxVoltage; voltage += VoltageIncrement) | ||
{ | ||
SetPortVoltage(device, voltage); | ||
if (CheckLinkState(device)) | ||
if (base.CheckLinkState(device)) | ||
{ | ||
SetPortVoltage(device, voltage + VoltageOffset); | ||
if (CheckLinkState(device)) | ||
{ | ||
// TODO: The RHS2116 headstage needs an additional reset after power on | ||
// to provide its device table. | ||
Thread.Sleep(500); | ||
device.Context.Reset(); | ||
return true; | ||
} | ||
else break; | ||
return CheckLinkState(device); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just noticed this now, and was really confused. If we just need to reset before the last check, why not simply add My suspicion is that perhaps this is related to the case where we want to just set a port voltage override and therefore the code does not go through this path? In that case, maybe the best would be to mark There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was addressed in #124 which does what you suggest. |
||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private void SetPortVoltage(DeviceContext device, uint voltage) | ||
private void SetPortVoltage(DeviceContext device, double voltage) | ||
{ | ||
const int WaitUntilVoltageOffSettles = 500; | ||
const int WaitUntilVoltageOnSettles = 500; | ||
device.WriteRegister(FmcLinkController.PORTVOLTAGE, 0); | ||
Thread.Sleep(WaitUntilVoltageOffSettles); | ||
device.WriteRegister(FmcLinkController.PORTVOLTAGE, voltage); | ||
Thread.Sleep(WaitUntilVoltageOnSettles); | ||
Thread.Sleep(500); | ||
device.WriteRegister(FmcLinkController.PORTVOLTAGE, (uint)(10 * voltage)); | ||
Thread.Sleep(500); | ||
} | ||
|
||
protected override bool CheckLinkState(DeviceContext device) | ||
{ | ||
// NB: The RHS2116 headstage needs an additional reset after power on to provide its device table. | ||
device.Context.Reset(); | ||
var linkState = device.ReadRegister(FmcLinkController.LINKSTATE); | ||
return (linkState & FmcLinkController.LINKSTATE_SL) != 0; | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the phase detector package used in the implementation, or just for examples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Should not be there. Also don't know why I committed this file.