Internship at RIKEN: 1.The Start

0 likes

Up until now, everything @SoySoy4444and I have learned about programming and engineering has from sources like Youtube, Udemy, or some online courses. While I have gained a considerable amount of knowledge(Soya, on the other hand, gained an astonishing amount of knowledge) on the topics that we tackled, this learning experience has been quite limited. In February, we had a chance to apply our coding skills in an online hackathon event where hundreds of participants from around the world competed to create a piece of software/hardware. We woke up at 5 am and worked on a project until the next morning(a post about this experience will be coming soon). We certainly gained a lot of experience during this intense 24-hour competition, but again, nobody would have the stamina to do this often!

We wanted something that would expose us to a research environment, something that would carry our knowledge on engineering and computer science to a higher level.

How we got the internship

We came across the organization called RIKEN. Founded in 1917, it is "Japan's largest comprehensive research institution renowned for high-quality research in a diverse range of scientific disciplines". It is the organization that discovered the 133rd element on the periodic table! Luckily, one of RIKEN's brain science laboratory is located in our city. Even though brain science is indeed a biological field of study, their research topic combines biology with robotics - "Using bio-mimetic controllers, we will work towards developing controllers that can learn autonomous behavior through the interaction of robot bodies and unknown environments." An internship at RIKEN would certainly be a surreal experience. And so, we wrote an email, introducing ourselves and providing an overview of our current achievements in computer science and engineering. After sending the email, we looked over the lab's website. The leader there is a Tokyo University Alumni, an MIT visiting student, and a researcher who has received several national research awards. The chance of us getting accepted for an internship just didn't seem likely. About a week later, we received a reply! It was the leader of the lab, accepting our request and inviting us to his lab.

Our first visit: 6th July, 2020

During the first visit, the lab leader talked to us about our interests and gave us a tour around the lab. The equipment, space, and the people - it was the environment for scientific research and innovation! After the tour, he showed us a slideshow about what the team has been working on and mentioned a side project, which he would like us to be part of. The project is about a robotic arm with a unique sensor. He told us that this project, as well as the lab, is sponsored by Toyota, as they were interested in the interdisciplinary overlap between engineering and biology. This robotic arm is intended to be applied in the medical field, to automate Nasopharyngeal Swab testing(the test for collecting clinical sample at the back of the nose) with more precision. He wanted us to assemble and write programs for this robotic arm and, as a target, to process a real-time image and have the robotic arm replicate the image with a pencil. Awestruck by the sound of the project, we started to have doubts about whether he had overestimated our capability and knowledge in the engineering discipline. Nevertheless, we will try our best, of course, as this is just a tremendous opportunity - working with professioinal researchers and having the chance to use industry-level equipment such as control boards from National Instrumment, high precision motors produced by Maxon, and more.

What's next

We received a sample script, from the lab leader, for sending digital and analog signals to the motors. The script uses a library produced by National Instrument called "Ni-DAQmx". We will be looking over the documentation before our next visit. During our next visit, we will start the assembling process of the robot, and begin controlling the robot.

Below is a snippet of the python sample script:

def ReadAnalogInput(Dname,ch):
    DD=Dname + '/ai' +str(ch)
    with nidaqmx.Task() as task:
        task.ai_channels.add_ai_voltage_chan(DD)
        out=task.read()
    return out

def WriteAnalogOutput(Dname,ch,value):
    DD=Dname + '/ao' +str(ch)
    with nidaqmx.Task() as task:
        task.ao_channels.add_ao_voltage_chan(DD)
        task.write(value)

def ReadDigitalInput(Dname,ch):
    DD=Dname + '/port0/line' +str(ch)
    with nidaqmx.Task() as task:
        task.di_channels.add_di_chan(DD)
        out=task.read()
    return out

def WriteDigitalOutput(Dname,ch,value):
    DD=Dname + '/port0/line' +str(ch)
    with nidaqmx.Task() as task:
        task.do_channels.add_do_chan(DD)
        task.write(value)

def ReadAngle(Dname,ch):
    DD=Dname + '/ctr' +str(ch)
    with nidaqmx.Task() as task:
        task.ci_channels.add_ci_ang_encoder_chan(counter = DD, decoding_type = EncoderType.X_4, units=AngleUnits.DEGREES, pulses_per_rev=24)
        ang=task.read()
    return ang


def VoltageOutput(Dname,Vel):
    if Vel>0:
        WriteAnalogOutput(Dname,0,Vel)
        WriteDigitalOutput(Dname,1,True)
        WriteDigitalOutput(Dname,0,False)
    elif Vel<0:
        WriteAnalogOutput(Dname,0,-Vel)
        WriteDigitalOutput(Dname,0,True)
        WriteDigitalOutput(Dname,1,False)

def MotorStop(Dname):
    WriteDigitalOutput(Dname,0,False)
    WriteDigitalOutput(Dname,1,False)

def handler(signal, frame):
    MotorStop('Dev4')
    sys.exit(0)

def main():
    signal.signal(signal.SIGINT, handler)
    Dname='Dev4'   #Device name
    Dang=250    # Target Angle
    LoopN=800   # Number of Contrl Loop
    with nidaqmx.Task() as taskCNT, nidaqmx.Task() as taskAO, nidaqmx.Task() as taskAI, nidaqmx.Task() as taskDO0, nidaqmx.Task() as taskDO1:
        taskAO.ao_channels.add_ao_voltage_chan('Dev4/ao0')  # Task for output voltage
        taskAI.ai_channels.add_ai_voltage_chan('Dev4/ai0')  # Task for reading velocity
        taskDO0.do_channels.add_do_chan('Dev4/port0/line0') # Task for CW of motor rotation
        taskDO1.do_channels.add_do_chan('Dev4/port0/line1') # Task for CCW of Motor rotation
        taskCNT.ci_channels.add_ci_ang_encoder_chan(counter = 'Dev4/ctr0', decoding_type = EncoderType.X_4, units=AngleUnits.DEGREES, pulses_per_rev=512, initial_angle=0.0) # Task for read encoder
        POS=[0 for i in range(LoopN)] # Memory for position recording
        VEL=[0 for i in range(LoopN)] # Memory for Velocity recording
        OO=[0 for i in range(LoopN)] # Memory for output recording
        TIME=[0 for i in range(LoopN)] #Memory for Time recoridng
        taskCNT.start()  #start encoder counting
        Vel=0;
        Pang=0;
        i=0
        A=time.time()
        while i0:
                if oo>10:
                    oo=10           #max output is 10
                taskAO.write(oo)
                taskDO0.write(True)   #for CW motion DO0 1 DO1 0
                taskDO1.write(False)
            else:
                if oo<-10:
                    oo=-10
                taskAO.write(-oo)
                taskDO1.write(True)
                taskDO0.write(False)
            POS[i]=ang      
            VEL[i]=Vel      
            OO[i]=oo
            TIME[i]=time.time()-A
            i+=1

        MotorStop(Dname)
        np.savez('./RES',POS,VEL,OO)
        plt.figure(1)
        plt.cla
        plt.plot(TIME,POS)
        plt.figure(2)
        plt.cla
        plt.plot(TIME,VEL)
        plt.figure(3)
        plt.cla
        plt.plot(TIME,OO)
The code consists of lines that can control the analog input/output and digital input/output, as well as for instructions for the encoder in the motor to send feedback on the angle of the rotation. One of our conjectures is that, because we are using brushless DC motor, which according to our research, uses PWM, the "max 10v" in the code sample represents the maximum PWM voltage.


Leave a Comment
/200 Characters