Erfahrung mit I²C-Ansteuerung -SD20 Baustein- & IO Warrior24

Dies ist das deutsche Forum für alle Themen um den IO-Warrior. Beiträge bitte nur in Deutsch.

Moderator: Guido Körber

Post Reply
VERJ
Posts: 9
Joined: Tue Sep 25, 2012 3:55 pm

Erfahrung mit I²C-Ansteuerung -SD20 Baustein- & IO Warrior24

Post by VERJ »

Hallo Zusammen,

ich bin auf der Suche nach einer Lösung um 4 Servos kostengüstig in einem Schülerprojekt
mit dem IO Warrior 24 zu bereiben.

Dabei habe ich den I2C Baustein (http://www.roboter-teile.de/Oxid/Motor- ... ler%20SD20) SD20 gefunden.

Hat jemand diesen Baustein schon mal mit dem IO Warrior 24 eingesetzt? Ich würde mich über Infos freuen.

Gruß
VERJ
towaibw
Posts: 198
Joined: Sat Dec 27, 2003 10:55 pm
Location: Berlin / Germany
Contact:

für Java gibt es da etwas

Post by towaibw »

Für den SD20 gibt es in IOWJ (Achtung Reklame!) eine Klasse. Auch ein Servo ist als Klasse bereits realisiert.
Zu allem Überfluß existiert auch noch ein kleines Testprogramm. Das alles in Java:

Code: Select all

/*
 * This File is part of the iowj-project   
 * $Id$
 * Copyright (C)2010 by Thomas Wagner
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
 
package de.wagner_ibw.test;

import de.wagner_ibw.iow.AbstractIowDevice;
import de.wagner_ibw.iow.IowFactory;
import de.wagner_ibw.iow.i2c.I2C;
import de.wagner_ibw.iow.i2c.SD20;
import de.wagner_ibw.iow.misc.ServoES05JR;

/**
 * It is a simple test program for the ServoES05JR class.
 * @author Thomas Wagner
 */
public class ServoTest {
		
	private IowFactory   	    devs;
	private AbstractIowDevice	dev;
	private I2C 		          i2c;
	private SD20		          sd;
	private ServoES05JR	      s;
	
	/**
	 * Constructor.
	 */
	public ServoTest() {
		devs = IowFactory.getInstance();
		if (devs.getNumDevices() == 0) {
			System.out.println("Cannot find any connected IOW device(s)!");
			devs.exit(-1);
		} 
	}
		
	/**
	 * @param args Not used here.
	 */
	public static void main(String[] args) {
		ServoTest st = new ServoTest();
		st.doit();
		st.devs.exit(0);
	}
	
	/**
	 * Do all that work.
	 */
	private void doit() {
		try{
			dev = devs.getIowDevice();
						 
			i2c = new I2C(I2C.I2C_SPEED_400KHZ);
			 
			dev.addSpecialModeFunctionImpl(i2c);
			
			sd = new SD20();
		
			i2c.addI2CDevice(sd);
		
			s = new ServoES05JR(sd,1);
		
			System.out.println("----- ES05JR -----\n"+dev);
			System.out.println(sd);					
			System.out.println(s);
			System.out.println("\n");
	
		
			for(int i = 0; i < 2; i++) {
				try {
					s.setPosition(1);
					Thread.sleep(1000);
						
					for (int j = 1; j < 256; j++) {
						s.setPosition(j);
						Thread.sleep(10);
					}
	
					Thread.sleep(2000);
					s.setPosition(1);
					System.out.println(s);
					Thread.sleep(2000);
					s.setPosition(127);
					System.out.println(s);
					Thread.sleep(2000);
					s.setPosition(255);
					System.out.println(s);
					Thread.sleep(2000);
					s.setPosition(127);
					System.out.println(s);
					Thread.sleep(2000);
					s.setPosition(1);
					System.out.println(s);
					
					
					System.out.println("\n");
				} catch(Exception e) {
					System.out.println(e);
				}
			}	
		}
		catch(Exception e ){
			e.printStackTrace();
		}
	}
}
Der Code ist ohne Änderungen auch für den IO-Warrior 40 oder 56 zu gebrauchen.

Gruß
Thomas
Post Reply