Monday, August 2, 2021
python to control the stepmotor nema11
#finally it works! the wait time has to be finetuned to prevent the wobbling
import RPi.GPIO as GPIO
from RpiMotorLib import RpiMotorLib
import time
################################
# RPi and Motor Pre-allocations
################################
#
#define GPIO pins
GpioPins=[21,22,23,24]
# Declare a instance of class pass GPIO pins numbers and the motor type
#mymotortest = RpiMotorLib.A4988Nema(direction, step, (21,21,21), "DRV8825")
mymotortest = RpiMotorLib.BYJMotor("Mymotorone", "Nema")
#mymotortest = RpiMotorLib.A4988Nema(direction, step, (21,21,21), "A4948")
for i in range(5):
time.sleep(1)
mymotortest.motor_run(GpioPins, 0.0002, 1600, True, False, "full", .05)#pins, wait, steps, ccwise, verbose, steptype,inidelay
time.sleep(1)
mymotortest.motor_run(GpioPins, 0.0003, 1600, False, False, "full", .05)#pins, wait, steps, ccwise, verbose, steptype,inidelay
GPIO.cleanup() # clear GPIO allocations after run
Monday, July 19, 2021
open image sequence with filter of more than one criteria
It took some effort, but I figure out the code should be:
File name contains: (.*_F_.*tif)
This means there is a "_F" in file name and the type of images is tif
Friday, July 2, 2021
3d mouse brain and skull model
Very nice 3d model:
https://www.thingiverse.com/thing:3079327
This is how to make it smaller in file size so it can be imported to Tinkercad
https://3dtomorrow.com/2019/07/17/how-to-reduce-file-size-in-meshmixer/
Wednesday, June 30, 2021
To convert 2-column vectors to 5 column vectors for comparison of grouped data
target=half_decay;
grp=1:5;
grouplength=ones(1,5);
for i=1:5
grouplength(i)=length(find(target(:,2)==i));
end
largest_groupnumber=max(grouplength);
finalmatrix=NaN(largest_groupnumber,5);
for ii=1:5
for iii=1:grouplength(ii)
aa=target(find(target(:,2)==ii));
finalmatrix(iii,ii)=aa(iii);
end
end
Wednesday, February 17, 2021
Language tips: dire
There is a burning need to develope effective therapeutics toward... : Burning to "dire"
Friday, December 4, 2020
Add arrays to a structure
Num2cell is a useful function. The important part is that it could convert an array (m x n) to scalar array (y x 1) so you could add this to a structure.
aa=table2struct(readtable((fullfile(filePath0,'curve','params',file0(1).name))));
%This is the structure you want to add new values to
file1=dir(fullfile(filePath0,'ROI_dark*.mat'));
dark_files=load(fullfile(filePath0,file1(1).name),'Intensity','dff0');
%Then you got two variables, both are two dimensional array. To add them, you have to first convert them into cell:
cc=num2cell(dark_files.Intensity,1);
%Then add them:
[aa.dark_Intensity]=cc{:};
Friday, November 27, 2020
low cost microscopes
1. smart design
https://www.osapublishing.org/DirectPDFAccess/73B7846B-A422-B22A-AA38B1E6131DE5F9_429869/boe-11-5-2447.pdf?da=1&id=429869&seq=0&mobile=no
2. not fancy
https://www.instructables.com/ARPM-Another-raspberry-pi-microscope-made-from-Ple/
control of motion (for adujustment of focus):
https://www.robotshop.com/community/forum/t/retracting-linear-actuator-with-raspberry-pi/43024/6
Since you want to control the speed and the position of the actuator, I would recommend using a linear actuator including a potentiometer like this one: https://www.robotshop.com/en/l16-linear-actuator-351-50mm-12v-w--potentiometer-feedback.html 89
This will allow you to track the position of the actuator. Note that you will need a microcontroller to read the value of the potentiometer.
To control the speed of the actuator I would recommend any regular DC motor driver depending on the specifications of the actuator.
Subscribe to:
Posts (Atom)