Last week, Stéphane Cousot wrote a basic library for communicating between Processing and Pinguino. This the first release but it was tested and is fully functional. Stéphane made a package with a processing sketch and the Pinguino program associated. You can download this package on Stéphane website.
This library is the result of our work with Douglas Edric Stanley. The goal is to build a USB interface wich can be driven by many different software ( Processing, Python, Pure data, java ... ).
Pinguino is the hardware part of this project.
Douglas Edric Stanley Blog.
Monday, March 16, 2009
Processing library for Pinguino
Libellés :
Pinguino Processing
Sunday, March 15, 2009
8 PWM output on Pinguino !!
This is an interrupt code example. It show how to build 8 PWM output on pin 0 to 7 with the timer 1. The PWM frequency is about 400 Hz. With the 2 analogWrite output, you can now drive 10 PWM outputs and this code can be adapted to drive 16 PWM outputs.
Applications are motors, lights and others analogic outputs.
// How to use interrupt on Pinguino
// add 8 analog outputs ( PWM ) to your Pinguino
// can be extended to 16
// Jean-Pierre MANDON 2009
08/04/2009
When copied to the blog, this file is corrupted.
You can download the source here.
Applications are motors, lights and others analogic outputs.
// How to use interrupt on Pinguino
// add 8 analog outputs ( PWM ) to your Pinguino
// can be extended to 16
// Jean-Pierre MANDON 2009
When copied to the blog, this file is corrupted.
You can download the source here.
Libellés :
tutorial (expert)
CodeBlocks model Released !!
CodeBlocks model for Pinguino released to be conform to beta 5 of the IDE.
The new file can be downloaded here..........
The new file can be downloaded here..........
Libellés :
tutorial (expert)
How to use Interrupt with Pinguino......
With beta 5 you can use interrupt in a Pinguino program. This is a simple example to blink a led with timer 1. Nothing to do in the main loop because level of the led is changed by the interrupt routine.
// How to use interrupt on Pinguino
// simple example blink a led with timer 1
// led is connected on output 0
// Jean-Pierre Mandon 2009
void UserInterrupt()
{
// timer 1 interrupt flag in register PIR1
if (PIR1bits.TMR1IF)
{
// reset interrupt flag
PIR1bits.TMR1IF=0;
// reverse state of pin 0 ( blink )
digitalWrite(0,digitalRead(0)^1);
}
}
void setup()
{
// led is connected on output 0
pinMode(0,OUTPUT);
// timer 1 configuration
// you can write T1CON=0xB1; or
// timer1 register is 16 bits
T1CONbits.RD16=1;
// clock source for timer 1 is derived from clock
T1CONbits.T1RUN=0;
// prescale value 1/8
T1CONbits.T1CKPS1=1;
T1CONbits.T1CKPS0=1;
// timer 1 oscillator is shut off ( internal clock )
T1CONbits.T1OSCEN=0;
// T1SYNC is not used ( internal clock )
// timer clock is internal clock ( Fosc/4 )
T1CONbits.TMR1CS=0;
// timer 1 is On
T1CONbits.TMR1ON=1;
// FOSC is 48 Mhz => Internal clock = 48 Mhz / 4 = 12 Mhz
// clock period is 83 nS
// prescale for timer 1 is 8 => clock period for timer 1 is 667 nS
// timer 1 is incremented every 667 nS
// timer 1 is a 16 bits register, it will overflow every 667nS*65536 = 43.6 mS
// when timer 1 overflow it generate an interrupt
// Interrupt configuration
// enable interrupt for timer1 in register PIE1
PIE1bits.TMR1IE=1;
// Here you can write INTCON|=0xC0; or
// enable peripheral interrupt
INTCONbits.PEIE=1;
// global enable interrupt
INTCONbits.GIE=1;
// now an interrupt will be generated by timer1 every 43,6 mS
}
void loop()
{
// nothing to do in the main loop :-)
}
// How to use interrupt on Pinguino
// simple example blink a led with timer 1
// led is connected on output 0
// Jean-Pierre Mandon 2009
void UserInterrupt()
{
// timer 1 interrupt flag in register PIR1
if (PIR1bits.TMR1IF)
{
// reset interrupt flag
PIR1bits.TMR1IF=0;
// reverse state of pin 0 ( blink )
digitalWrite(0,digitalRead(0)^1);
}
}
void setup()
{
// led is connected on output 0
pinMode(0,OUTPUT);
// timer 1 configuration
// you can write T1CON=0xB1; or
// timer1 register is 16 bits
T1CONbits.RD16=1;
// clock source for timer 1 is derived from clock
T1CONbits.T1RUN=0;
// prescale value 1/8
T1CONbits.T1CKPS1=1;
T1CONbits.T1CKPS0=1;
// timer 1 oscillator is shut off ( internal clock )
T1CONbits.T1OSCEN=0;
// T1SYNC is not used ( internal clock )
// timer clock is internal clock ( Fosc/4 )
T1CONbits.TMR1CS=0;
// timer 1 is On
T1CONbits.TMR1ON=1;
// FOSC is 48 Mhz => Internal clock = 48 Mhz / 4 = 12 Mhz
// clock period is 83 nS
// prescale for timer 1 is 8 => clock period for timer 1 is 667 nS
// timer 1 is incremented every 667 nS
// timer 1 is a 16 bits register, it will overflow every 667nS*65536 = 43.6 mS
// when timer 1 overflow it generate an interrupt
// Interrupt configuration
// enable interrupt for timer1 in register PIE1
PIE1bits.TMR1IE=1;
// Here you can write INTCON|=0xC0; or
// enable peripheral interrupt
INTCONbits.PEIE=1;
// global enable interrupt
INTCONbits.GIE=1;
// now an interrupt will be generated by timer1 every 43,6 mS
}
void loop()
{
// nothing to do in the main loop :-)
}
Libellés :
tutorial (expert)
Sunday, March 8, 2009
beta 5 for MAC OSX......
Libellés :
pinguino software
Pinguino beta 5 Windows....
The windows packaging of beta 5 is Here........
Libellés :
pinguino software
Pinguino beta 5 Linux is available......
The beta 5 release is online with many new improvements.
- Full support of UserInterrupt
- millis() instruction
- fast analogWrite on output 11 and 12 without affect on the process speed
- standart c variable initialisation
- possible use of user libraries.
You can download this version for Linux here.......
Windows and MAC OS version will be soon available.
- Full support of UserInterrupt
- millis() instruction
- fast analogWrite on output 11 and 12 without affect on the process speed
- standart c variable initialisation
- possible use of user libraries.
You can download this version for Linux here.......
Windows and MAC OS version will be soon available.
Libellés :
pinguino software
Friday, March 6, 2009
Pinguino on a proto-board....
Fabi from Madrid built his Pinguino on a proto-board. Very good idea !!
Maybe we can build a tiny Pinguino on a breadboard :-)
I will try..............
Libellés :
build Pinguino
Thursday, March 5, 2009
Pinguino with Processing
I tried to connect Pinguino with Processing with the LibUSB java wrapper. It works without problem. This is the Processing test sketch:
// This is a simple example to communicate with Pinguino
// based on the LibusbJava wrapper http://libusbjava.sourceforge.net/wp/
// Jean-Pierre MANDON 05/03/2009
import ch.ntb.usb.Device;
import ch.ntb.usb.USB;
import ch.ntb.usb.USBException;
import ch.ntb.usb.logger.LogUtil;
// define Pinguino Product ID and Vendor ID
int VID = 0x04D8;
int PID = 0xFEAA;
// declare public USB device
Device Pinguino;
// declare output buffer
byte[] data = new byte[] { 'W', -1 };
void setup()
{
size(400,100);
frameRate(20);
LibusbJava.usb_init(); // init libusbjava
LibusbJava.usb_find_busses(); // find all usb busses
LibusbJava.usb_find_devices(); // find all devices
try {
Pinguino=USB.getDevice( (short) VID , (short) PID ); // create a new device
Pinguino.open(3,0,-1); // try to open it ( configuration 3, interface 0 )
println("Pinguino found"); // it's OK
}
catch (USBException e) // error
{
println("Pinguino not found"); // Pinguino is not connected !!
}
}
byte lastposition=-1;
byte position;
void draw()
{
background(204);
rect(mouseX,40,20,20); // draw a rectangle
position=byte(mouseX/50); // position modulo 8
if (position!=lastposition)
{
try {
if (lastposition!=-1) data[1]=lastposition;
else data[1]='C'; // WC clear all leds
Pinguino.writeBulk(0x01,data,2,200,false); // send command to Pinguino
data[1]=position; // led to be lighted
Pinguino.writeBulk(0x01,data,2,200,false); // send command
lastposition=position;
}
catch (USBException e) {}
}
}
void stop()
{
data[1]='C'; // clear all when stop
try {
Pinguino.writeBulk(0x01,data,2,200,false);
}
catch (USBException e) {}
}
Now this is the Pinguino side:
// test Pinguino with Processing
// Jean-Pierre MANDON 2009
int i;
uchar caractere,caractere1;
void setup()
{
for (i=0;i<8;i++)
{
pinMode(i,OUTPUT);
digitalWrite(i,LOW);
}
}
void loop()
{
if (USB.available())
{
caractere=USB.read();
if (caractere=='W') if (USB.available())
{
caractere1=USB.read();
if (caractere1=='C')
for (i=0;i<8;i++) digitalWrite(i,LOW);
else
digitalWrite(caractere1,digitalRead(caractere1)^1);
}
}
}
And you can see the result here.
// This is a simple example to communicate with Pinguino
// based on the LibusbJava wrapper http://libusbjava.sourceforge.net/wp/
// Jean-Pierre MANDON 05/03/2009
import ch.ntb.usb.Device;
import ch.ntb.usb.USB;
import ch.ntb.usb.USBException;
import ch.ntb.usb.logger.LogUtil;
// define Pinguino Product ID and Vendor ID
int VID = 0x04D8;
int PID = 0xFEAA;
// declare public USB device
Device Pinguino;
// declare output buffer
byte[] data = new byte[] { 'W', -1 };
void setup()
{
size(400,100);
frameRate(20);
LibusbJava.usb_init(); // init libusbjava
LibusbJava.usb_find_busses(); // find all usb busses
LibusbJava.usb_find_devices(); // find all devices
try {
Pinguino=USB.getDevice( (short) VID , (short) PID ); // create a new device
Pinguino.open(3,0,-1); // try to open it ( configuration 3, interface 0 )
println("Pinguino found"); // it's OK
}
catch (USBException e) // error
{
println("Pinguino not found"); // Pinguino is not connected !!
}
}
byte lastposition=-1;
byte position;
void draw()
{
background(204);
rect(mouseX,40,20,20); // draw a rectangle
position=byte(mouseX/50); // position modulo 8
if (position!=lastposition)
{
try {
if (lastposition!=-1) data[1]=lastposition;
else data[1]='C'; // WC clear all leds
Pinguino.writeBulk(0x01,data,2,200,false); // send command to Pinguino
data[1]=position; // led to be lighted
Pinguino.writeBulk(0x01,data,2,200,false); // send command
lastposition=position;
}
catch (USBException e) {}
}
}
void stop()
{
data[1]='C'; // clear all when stop
try {
Pinguino.writeBulk(0x01,data,2,200,false);
}
catch (USBException e) {}
}
Now this is the Pinguino side:
// test Pinguino with Processing
// Jean-Pierre MANDON 2009
int i;
uchar caractere,caractere1;
void setup()
{
for (i=0;i<8;i++)
{
pinMode(i,OUTPUT);
digitalWrite(i,LOW);
}
}
void loop()
{
if (USB.available())
{
caractere=USB.read();
if (caractere=='W') if (USB.available())
{
caractere1=USB.read();
if (caractere1=='C')
for (i=0;i<8;i++) digitalWrite(i,LOW);
else
digitalWrite(caractere1,digitalRead(caractere1)^1);
}
}
}
And you can see the result here.
Libellés :
Pinguino Processing
Subscribe to:
Posts (Atom)