IO Board

Post Reply
rmolin88
Posts: 12
Joined: Sun Sep 08, 2013 3:56 pm
languages_spoken: english, spanish
ODROIDs: U2
Has thanked: 0
Been thanked: 0
Contact:

IO Board

Unread post by rmolin88 » Tue Sep 10, 2013 2:10 pm

Hi, I purchased the IO Board, and trying just to run the sample codes on the git but I get this error. Maybe I am misunderstanding something. I am very new to linux and python.I am using Ubuntu 12.04. This is the command line I am using:

Code: Select all

~/Downloads/Odroid-USBIO-master/Odroid-USBIO-master/usbio/linux$ sudo python ./sfr_gpio.py
and this is what happens:

Code: Select all

File "./sfr_gpio.py", line 17, in <module>
    print rom_version(usb)		# print rom version
  File "/home/viki/Downloads/Odroid-USBIO-master/Odroid-USBIO-master/usbio/linux/hk_usb_io.py", line 101, in rom_version
    ret = dev.read(0x81, 64, 0, 100)
  File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 661, in read
    self.__get_timeout(timeout)
  File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 559, in intr_read
    timeout)
  File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 648, in __read
    _check(retval)
  File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 403, in _check
    raise USBError(_str_error[ret], ret, _libusb_errno[ret])
usb.core.USBError: [Errno 110] Operation timed out

I ran successfully the usbio Example host software source code for Ubuntu.

Thank you in advance

mdrjr
Site Admin
Posts: 11726
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Has thanked: 1 time
Been thanked: 13 times
Contact:

Re: IO Board

Unread post by mdrjr » Wed Sep 11, 2013 8:24 am

You can poke mlinuxguy :) He might have the answer for you :)

rmolin88
Posts: 12
Joined: Sun Sep 08, 2013 3:56 pm
languages_spoken: english, spanish
ODROIDs: U2
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by rmolin88 » Wed Sep 11, 2013 8:31 am

I pm him this afternoon but still have received no answer.

Thank you for the suggestion.

mdrjr
Site Admin
Posts: 11726
Joined: Fri Feb 22, 2013 11:34 pm
languages_spoken: english, portuguese
ODROIDs: -
Location: Brazil
Has thanked: 1 time
Been thanked: 13 times
Contact:

Re: IO Board

Unread post by mdrjr » Wed Sep 11, 2013 8:33 am

Sorry that I can't help you.. I never touched one of those boards.. so.. out of my expertise..

rmolin88
Posts: 12
Joined: Sun Sep 08, 2013 3:56 pm
languages_spoken: english, spanish
ODROIDs: U2
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by rmolin88 » Wed Sep 11, 2013 8:37 am

No problem. Just the suggestion along is valuable. I appreciate it :)))

mlinuxguy
Posts: 840
Joined: Thu Feb 28, 2013 10:28 am
languages_spoken: english
ODROIDs: X, X2, XU, XU3, XU4, C1, C1+, C2, N1, USB-IO
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by mlinuxguy » Wed Sep 11, 2013 2:26 pm

The code sequence you are in is:

Code: Select all

#-------------- USB init required --------
usb = init()                    # init the USB IO board
#---------------
print module_version()          # print python module version
print rom_version(usb)          # print rom version
^^^ Fail here
This code is after the init() meaning it found your USBIO board, yet fails to read the rom version

Code: Select all

def rom_version(dev):                   # get PIC ROM version
        # read ROM version
        dev.write(1, [u_rom], 0, 100)
        ret = dev.read(0x81, 64, 0, 100)  <--- fails here
This implies that you have not flashed the USBIO board with the ROM found on GITHUB (hex file):
https://github.com/hardkernel/Odroid-US ... uction.hex

If you have the default ROM there is not a get ROM version routine on the USBIO board. You will need to flash this hex file onto the USBIO board to gain access to my extended functions on the board. The other option would be comment out my rom version print routine and avoid any of my ROM additions (just use SFR calls).

rmolin88
Posts: 12
Joined: Sun Sep 08, 2013 3:56 pm
languages_spoken: english, spanish
ODROIDs: U2
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by rmolin88 » Thu Sep 12, 2013 6:45 am

Thanks a million. I knew it was something silly I was missing. Thanks again

rmolin88
Posts: 12
Joined: Sun Sep 08, 2013 3:56 pm
languages_spoken: english, spanish
ODROIDs: U2
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by rmolin88 » Fri Sep 20, 2013 4:23 am

Hello, I was wondering if you could help me with another problem I am having.

I want to run a motor and a servo through the IO Board. The problem is that the IO clock frequency is too high and I need PWM with 50-100Hz of frequency. The things I have tried are toggling a pin but is too instable. I tried Compare Mode, but I would like to stay away from Interrupts. I tried lowering the clock speed of the microcontroller but that did not work for me neither. Down below are a couple of lines with the things I have tried. If you could help me with this I would really appreciate it.

In this line I tried changing the oscillator source to get 500kHz clock

Code: Select all

sfr_set_reg(	usb, pwm.OSCCON, 0b0010c0111)


In these lines set up the compare to try a 20ms Period 10%duty cycle

Code: Select all

sfr_set_regbit(	usb, pwm.TRISC, 1, 0)		#Cleaering RC1 to use it as output
	sfr_set_reg(	usb, pwm.CCP2CON, 0x0b)		#compare mode:toggle output pin on match
	sfr_set_reg(	usb, pwm.CCPR2H, duty_cycle_MSB)
	sfr_set_reg(	usb, pwm.CCPR2L, duty_cycle_LSB)
	sfr_set_reg(	usb, pwm.T1CON, 0b00110001)			#selecting Timer1 with Fosc/4 and 

mlinuxguy
Posts: 840
Joined: Thu Feb 28, 2013 10:28 am
languages_spoken: english
ODROIDs: X, X2, XU, XU3, XU4, C1, C1+, C2, N1, USB-IO
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by mlinuxguy » Fri Sep 20, 2013 5:13 am

Did you see my sfr_pwm example on github?
https://github.com/hardkernel/Odroid-US ... sfr_pwm.py

line 36-39 shows how to compute the frequency
#- PWM Period = [PR2 + 1] * 4 * TOSC * TMR2 Prescale Value
# - 3,750 Hz = (199 + 1) * 4 * 1/48,000,000 * 16
#PR2 = 199;

That computed value for PR2 is setup via this code:
sfr_set_reg( usb, pwm.PR2, 199) # load with PWM period value

Solving the equations for various PR2 values yeilds

Code: Select all

PR2    1/value           Freq
199	0.0002666667	3750
900	0.0012013333	832.4084350721
2000	0.002668	374.8125937031
3000	0.0040013333	249.9166944352
4000	0.0053346667	187.4531367158
5000	0.006668	149.9700059988
6000	0.0080013333	124.9791701383
7000	0.0093346667	107.1275532067
8000	0.010668	93.7382827147
9000	0.0120013333	83.3240751028
10000	0.0133346667	74.9925007499

rmolin88
Posts: 12
Joined: Sun Sep 08, 2013 3:56 pm
languages_spoken: english, spanish
ODROIDs: U2
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by rmolin88 » Fri Sep 20, 2013 5:20 am

I built on it. But my problem is that I thought I read PR2 was only an 8 bit regiater , therefore I was not going to be able to store a value higher than 255.

But if I am then that is great.

Than you once again

rmolin88
Posts: 12
Joined: Sun Sep 08, 2013 3:56 pm
languages_spoken: english, spanish
ODROIDs: U2
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by rmolin88 » Fri Sep 20, 2013 5:44 am

Actually it is 8 bit this is the error I get when I try to put 10 000 into PR2

Code: Select all

Traceback (most recent call last):
  File "./sfr_pwm.py", line 57, in <module>
    my_pwm_init(0x64)		# 50% duty cycle @50khz
  File "./sfr_pwm.py", line 41, in my_pwm_init
    sfr_set_reg(   usb, pwm.PR2, 10000)	# load with PWM period value
  File "/home/reinaldo/Dropbox/Fall2013/Robots/Code/Sample Code/hk_usb_io.py", line 164, in sfr_set_reg
    a[11] = rval			# value to set
OverflowError: unsigned byte integer is greater than maximum

mlinuxguy
Posts: 840
Joined: Thu Feb 28, 2013 10:28 am
languages_spoken: english
ODROIDs: X, X2, XU, XU3, XU4, C1, C1+, C2, N1, USB-IO
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by mlinuxguy » Fri Sep 20, 2013 6:47 am

Its been a while since I looked at the PWM code, you are correct PR2 is 8-bit
With the default clock of 48mhz you will not get a low enough frequency to hit 50 hz
The clock will have to be changed...

However, I am not sure you can do that without messing up USB communication
https://github.com/hardkernel/Odroid-US ... ain.c#L754

Perhaps ODROID would know about changing the clock divider and USB communications
https://github.com/hardkernel/Odroid-US ... main.c#L98

I have loaned out my USBIO board so am unable test any changes for now

rmolin88
Posts: 12
Joined: Sun Sep 08, 2013 3:56 pm
languages_spoken: english, spanish
ODROIDs: U2
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by rmolin88 » Fri Sep 20, 2013 7:10 am

Yeah it looks like this one is kind of a pickle. I am going to do some more reading
Maybe the Enhanced Pwm would let me. But thank you for your help. I will keep posting any progress here.

dbrobo
Posts: 8
Joined: Sun Feb 24, 2013 5:10 pm
languages_spoken: english
ODROIDs: odroid-u2
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by dbrobo » Tue Oct 01, 2013 9:06 am

Hi.

I'm trying to find out if I can use the IO board (with Odroid-U2 running Ubuntu) for controlling servos (PWM output) and taking in (PWM input) radio receiver pwm inputs channels.

Question: how many can I possibly configure as PWM inputs and outputs on one IO Board and which pins can be assigned as such?

..Would greatly appreciate any inputs.

All the best.
mlinuxguy wrote:Did you see my sfr_pwm example on github?
https://github.com/hardkernel/Odroid-US ... sfr_pwm.py

line 36-39 shows how to compute the frequency
#- PWM Period = [PR2 + 1] * 4 * TOSC * TMR2 Prescale Value
# - 3,750 Hz = (199 + 1) * 4 * 1/48,000,000 * 16
#PR2 = 199;

That computed value for PR2 is setup via this code:
sfr_set_reg( usb, pwm.PR2, 199) # load with PWM period value

Solving the equations for various PR2 values yeilds

Code: Select all

PR2    1/value           Freq
199	0.0002666667	3750
900	0.0012013333	832.4084350721
2000	0.002668	374.8125937031
3000	0.0040013333	249.9166944352
4000	0.0053346667	187.4531367158
5000	0.006668	149.9700059988
6000	0.0080013333	124.9791701383
7000	0.0093346667	107.1275532067
8000	0.010668	93.7382827147
9000	0.0120013333	83.3240751028
10000	0.0133346667	74.9925007499

User avatar
odroid
Site Admin
Posts: 32368
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 147 times
Been thanked: 325 times
Contact:

Re: IO Board

Unread post by odroid » Tue Oct 01, 2013 10:33 am

Refer below image and the datasheet of PIC18F45K50 to count the available PWM IOs.

Image

bounty
Posts: 8
Joined: Fri Nov 08, 2013 10:41 pm
languages_spoken: english, german
ODROIDs: odriud-xu
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by bounty » Tue Jan 21, 2014 10:28 pm

Hey,
is there any progress?
Is it possible to generate PWMs with 50Hz (for servo control)?

greetings

rmolin88
Posts: 12
Joined: Sun Sep 08, 2013 3:56 pm
languages_spoken: english, spanish
ODROIDs: U2
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by rmolin88 » Wed Jan 22, 2014 4:24 am

no its not possible at least I couldn't make it happen.

bounty
Posts: 8
Joined: Fri Nov 08, 2013 10:41 pm
languages_spoken: english, german
ODROIDs: odriud-xu
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by bounty » Wed Jan 22, 2014 5:27 am

Thank you for your reply.
Too bad that it is not working.

tanvirkhan1
Posts: 3
Joined: Thu Jan 15, 2015 4:58 pm
languages_spoken: english
ODROIDs: odroid Usb IO Board
Has thanked: 0
Been thanked: 0
Contact:

Re: IO Board

Unread post by tanvirkhan1 » Thu Jan 15, 2015 7:51 pm

Hi everybody.
I want to make digital thermometer using IO board and want to have its display on android device. what changes I have to make in c code?
I want to use RA0 pin as analog which already is. I have connected LM35 on this pin. how can i get accurate temperature values. Thanx

User avatar
odroid
Site Admin
Posts: 32368
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID
Has thanked: 147 times
Been thanked: 325 times
Contact:

Re: IO Board

Unread post by odroid » Thu Jan 15, 2015 9:18 pm

Do not wake up this sleeping thread.
Open a new thread in this forum.
http://forum.odroid.com/viewforum.php?f=87

Post Reply

Return to “Hardware and peripherals”

Who is online

Users browsing this forum: No registered users and 2 guests