After testing the operation of the kxps5 accelerometer with i2c-tools i wrote a test application using the i2c-dev interface. If you want to test your code before you write a kernel driver this is definately a good place to start. Once i had the configuration registers set properly and i had a routine for reading the acceleration vectors I stripped down a ds1621 kernel driver to a bare minimum, and then built it back up again to work with the kxps5. I then bitbaked the kxps5 driver as a kernel module, along with hwmon and it works perfectly! Next i cross compiled qwt 5.2.0 and plotted the acceleration as function of time. The video below is taken with antialiased lines which slows down the refresh rate but makes them look nice. If you plot it without this enabled it runs very smoothly. Here you see the kxps5 running without an external low pass filter (the internal filter is 1kHz) and despite this the output is pretty stable. What impressed me the most is the sensitivity. When placed on a desk the free fall interrupt indicator lights up if you drop one of the little nuts from the friendlyarm LCD about 10cm away from the device!
The very kind people at www.andahammer.com were generous enough to send me a mini2440 cable kit! This will be much easier than chopping up 2.5″ IDE connectors! The kit has all the connections you could ever need and will certainly make things much easier!
After getting the DS1621 thermometer working on the I2C bus i now on plan on connecting something more complicated and very small! They probably won’t recommend it in the data sheet but you can solder LGA14 using a normal iron and some enamelled wire. My first attempt is below. Unfortunately i started with much thicker wire which subsequently pulled a pad off but the thinner 0.15mm stuff is fairly easy. Checking the connections with a multimeter revealed no short circuits.
The plan is try this again with the same device (without breaking it!) and then solder it to some veroboard to which i’ll connect one of my new cables
After building the temperature sensing I2C circuit i posted about before i compiled a kernel for the mini2440 which supported the DS1621 temperature sensor. Thanks to the existing kernel support this was remarkably easy.
All i had to do was edit /mini2440_defconfig in …/kernel/mini2440/arch/arm/configs and change line 1039 to:
CONFIG_SENSORS_DS1621=y
I compiled the kernel using the script i posted here interrupting the process after the git clones to change the line above and then allowing it to continue. I then booted the mini2440 and the sensor module was immediately available under:
root@mini2440:/sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0048# ls
alarms name temp1_max uevent
driver power temp1_max_alarm
hwmon subsystem temp1_min
modalias temp1_input temp1_min_alarm
The output on the DS1621 is controlled by the temp1_min and temp1_max thresholds. By default it goes high when temp1_input < temp1_min. You can view the temperature by reading temp1_input and you can adjust temp1_min and temp1_max by echoing the required threshold to the file, for example:
In this configuration the DS1621 output is high and drives the base of my transistor which switches on an LED. As soon as i heat the sensor the temperature goes above temp1_min the LED turns off.
Although i have no purpose for this circuit it serves as a proof of concept for installing I2C devices on the mini2440.
Here’s another pic with the power light on but the output off:
I’m fairly new to electronics and i’ve certainly never used I2C before so I built a simple circuit based on a DS1621 I2C thermometer as a test. I got this for a couple of pounds from the seller ‘crodnet’ on ebay.
I found an old 2.5″ laptop drive connector which wasn’t large enough to fit on CON5 so i chopped it up and put it on the camera interface. I wired up the SDA and SCL lines along with 3.3V and GND to the veroboard. I also soldered a couple of LEDs, one for the power light and the other wired up through a transistor with the base connected to the thermostat output on the DS1621. This pin can be programmed to go high at a particular temperature.
I then plugged it in and powered up the mini2440. Running i2cdetect showed a new device at 0×48. The other devices are the onboard EEPROM. Looking at the datasheet for the DS1621 the temperature can be read from the location 0xAA. I was able to observe the temperature in hex through i2cget. Converting the output 0×0016 to decimal gives 22.0 degrees. The sensor is pretty neat, it responds almost immediately to the presence of your finger.
Below are the I2C commands i used. I installed i2c tools using opkg.
root@mini2440:~# i2cdetect s3c2410-i2c
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file/dev/i2c-0.
I will probe address range 0x03-0x77.
Continue? [Y/n] Y 0123456789 a b c d e f
00: -------------------------- 10: -------------------------------- 20: -------------------------------- 30: -------------------------------- 40: ----------------48-------------- 50: UU UU UU UU ------------------------ 60: -------------------------------- 70: ----------------
root@mini2440:~# watch--interval=1 i2cget -y s3c2410-i2c 0x48 0xAA w
Every 1.0s: i2cget -y s3c2410-i2c 0x48 0xAA w Tue Sep 1523:31:252009
0x0016
Below is a picture of the device..it looks like a right mess but it works great!
The next stage is compile the driver from the lmsensors package…
Recent Comments