Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

k_madsen's Content

There have been 3 items by k_madsen (Search limited from 30-March 23)


By content type

See this member's

Sort by                Order  

#59459 Mcp23s17 (SPI) with NP2+

Posted by k_madsen on 30 July 2014 - 08:13 AM in Netduino Plus 2 (and Netduino Plus 1)

Hi

This simple code works with no interrupt and porta as out and port b as in adresse is 64 write and 65 read (all low)

 

setRegister(register , value);

byte readRegister(register);

 

using System;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
//using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
 
namespace addonkm
{
    class MCP23S17
    {
        const byte IODIRA = 0x00; //iodirektion register 1 = in  0 = out default = 1
        const byte IODIRB = 0x10;
        const byte IPOLA = 0x01; // invert pin om port   1 = invert  default = 0
        const byte IPOLB = 0x11;
        const byte GPINTNA = 0x02; //int on change 1 = aktiv  default = 0
        const byte GPINTNB = 0x12;
        const byte DEFVALA = 0x03; //def comp reg on chage ved int on def change der genereres et int hvis 1 bit ikke har samme polaritet som dette register hvis enablet(intcon) 
        const byte DEFVALB = 0x13;
        const byte INTCONA = 0x04; // int control register  1 = compare with DEFVALA 0 = compare with last pin value
        const byte INTCONB = 0x14;
        const byte IOCON = 0x05;  // io expander config register bit 7 = bank mirror seqop disslw haen odr intpol 0
        const byte GPPUA = 0x06;    // pullup ressistors
        const byte GPPUB = 0x16;
        const byte INTFA = 0x07;    //int flag register 1 = pin that coursed the interrupt
        const byte INTFB = 0x17;
        const byte INTCAPA = 0x08; // interrupt captured value
        const byte INTCAPB = 0x18;
        const byte GPIOA = 0x09;  //Port register read port value read 
        const byte GPIOB = 0x19;
        const byte OLATA = 0x0a;    // output latch register   write
        const byte OLATB = 0x1a;
 
        private byte adresse;
        private byte adrread;
 
        static SPI.Configuration spiNormal = new SPI.Configuration(Pins.GPIO_PIN_D7,
                                                                    false,
                                                                    0,
                                                                    0,
                                                                    false,
                                                                    true,
                                                                    10000,
                                                                    SPI_Devices.SPI1
                                                                    );
 
        SPI SPIBus = new SPI(spiNormal);
 
        public void setRegister(byte register, byte value)
        {
            byte[] buff = new byte[3];
            buff[0] = adresse;
            buff[1] = register;
            buff[2] = value;
            SPIBus.Write(buff);
        }
 
        public byte readRegister(byte register)
        {
            byte[] buff = new byte[3];
            byte[] readbuff = new byte[3];
 
            buff[0] = adrread;
            buff[1] = register;
            buff[2] = 0; //spi dummy
            SPIBus.WriteRead(buff, readbuff);
            return readbuff[2];
        }
 
        private MCP23S17()
        {
        }
 
        public MCP23S17(byte adress)
        {
            adresse = (byte)(adress << 1);
            adrread = (byte)(adresse | 1);
 
            //saet port a til out og port b ind
            setRegister(IODIRA, 0); // alle bit out
            setRegister(GPPUA , 0xff); // alle pull op trans on
            setRegister(GPPUB, 0xff);
            setRegister(IOCON, 0xe2);
        }
    }
}



#59397 Control 80V DC Motor/Bulb Using Netduino 2

Posted by k_madsen on 25 July 2014 - 08:28 PM in General Discussion

G320X Digital Servo Drive this is hit all your needs inclusive with your incuranse.

 

regards

Kim




#59385 Control 80V DC Motor/Bulb Using Netduino 2

Posted by k_madsen on 25 July 2014 - 08:43 AM in General Discussion

I'm very new to electronics and I really like netdiuno, it can do exactly what I need. But I dont know how, at all. I will be very thankful if anyone can help. So I've attached an image to explain in details what I want to do.
 
I want to control a motor or bulb using 80V DC. I have DC output coming, but I dont know where to attach its +ve and -ve wires in netduino, or custom build something ?
 
In more simple way, when I press Start/Stop button, it should execute code something like this
 
 
 


static boolean MotorState = false;
static void StartButton()
{
  MotorState = true;
  while(MotorState)
  {
      motor.Start();
      Thread.Sleep(200);
      motor.Stop();
      Thread.Sleep(200);
      motor.Start();
      Thread.Sleep(10);
      motor.Stop();
      Thread.Sleep(100);
       //some sort of pattern
  }
}
static void StopButton()
{
  MotorState = false;
  motor.Stop();
}


Thanks

 

go to your local elektrician an get som relayes,
Here in DK it is only for for educated peoble to assamble elektroniks with a higher voltage than 36V.
You need a relay area that control the 80v and with 3.3v aktivate line.
Its a simple and good project. If you is fooling around it could make your fire incurence worth less.





home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.