CW2's Content - Netduino Forums - Page 2
   
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.

CW2's Content

There have been 148 items by CW2 (Search limited from 29-April 23)


By content type

See this member's


Sort by                Order  

#60304 wait on interrupt

Posted by CW2 on 30 September 2014 - 12:19 PM in Netduino Plus 2 (and Netduino Plus 1)

I didn't know that CW2. Somewhere I read the timing could be off by 4us

 
Well, it certainly takes some time for the native interrupt handler to execute, but I don't have any numbers  :(
 

I guess it also depends on what you consider low level code, as pin logic certainly could be considered really low level code

 
I guess in principle yes, but there is no code executed in the similar way like CPU executes its instructions. The pin logic input circuitry for edge detection is just a few logic gates (of course in real microcontroller it is a little bit more complex) and the interrupts are handled in a specialized unit (for ARM it is named Nested Vectored Interrupt Controller, NVIC) - only after validation, prioritization etc. NVIC notifies CPU, which then loads an interrupt handler address from vector table and starts executing the instructions. If you are interested in more details, have a look for example at the following document.
 

Is there any reason to re-use an event handler other than to save memory, and we are talking about a very tiny routine as discussed.

 
Personally, I sometimes re-use event handler when I need to handle multiple buttons, like this
...
InterruptPort button1 = new InterruptPort(Pins.GPIO_PIN_D0, ...);
InterruptPort button2 = new InterruptPort(Pins.GPIO_PIN_D1, ...);
InterruptPort button3 = new InterruptPort(Pins.GPIO_PIN_D2, ...);
...
button1.OnInterrupt += button_Interrupt;
button2.OnInterrupt += button_Interrupt;
button3.OnInterrupt += button_Interrupt;
...
void button_Interrupt(uint data1, uint state, DateTime time)
{
  var pin = (Cpu.Pin)data1;
  var on = (state != 0);

  switch(pin)
  {
    case Pins.GPIO_PIN_D0:
      ...
      break;
    case Pins.GPIO_PIN_D1:
      ...
      break;
    ...
  }
  // Or use data1 as array index, collection key etc.
}
It also makes diagnostic/troubleshooting easier in certain cases.



#60299 Max Power of Vdc Rails

Posted by CW2 on 30 September 2014 - 07:04 AM in General Discussion

5V

 

All Netduino-s use MC33269DT-5.0G (datasheet pdf) linear regulator (LDO), which has "Output Current in Excess of 800 mA".

 

3.3V

 

Netduino gen 1 use 3.3V variant of the same LDO (MC33269DT-3.3G), which means max 800 mA, but it is connected to 5V LDO, so the effective max current will be smaller, due to losses.

 

Netduino gen 2 use DC/DC converter based on ST1S12GR (datasheet pdf), which has output current 700 mA (again connected to 5V LDO, so the effective max current will be smaller due to losses).

 

The 125 mA limit applies to microcontroller pins, not power rails. You have to subtract current consumed by Netduino onboard circuitry (30 ~ 100 mA) from the regulator output.




#60298 wait on interrupt

Posted by CW2 on 30 September 2014 - 06:38 AM in Netduino Plus 2 (and Netduino Plus 1)

...it's not really an interrupt but a flag to the low level code to poll the pin and post an event at level change

 

Nope, there is no low level polling, but real hardware interrupts - when an interrupt condition is detected by pin logic a native interrupt handler is called, which creates event with timestamp and posts it into internal queue for the CLR to execute managed callbacks (event handlers).

 

@Grant: Have a look at InterruptPort class and its OnInterrupt event, you can re-use one event for multiple pins and then differentiate using its first parameter.




#60257 Help! I've accidentally bricked my brand-new Netduino 1 when updating...

Posted by CW2 on 27 September 2014 - 09:01 PM in Netduino 2 (and Netduino 1)

What guide are you following? ST tools do not work with Netduino 1, you have to use Atmel SAM-BA.




#60201 .NET Micro Framework V4.3 SDK-R2-Beta

Posted by CW2 on 24 September 2014 - 06:15 AM in General Discussion

Visual Studio 2013 extensions




#60200 .NET Micro Framework V4.3 SDK-R2-Beta

Posted by CW2 on 24 September 2014 - 06:10 AM in General Discussion

http://netmf.codeple...ses/view/133285
 
This is an SDK only updated release (e.g. porting kit and firmware don't change). The major highlights are:

  • Updated SDK to support use with Visual Studio 2013 (and experimental support for Visual Studio "14")
  • Split SDK installer from Visual Studio support. The SDK MSI now installs only the tools, and reference assemblies (like the desktop versions). A separate VSIX package installs to each supported version of Visual Studio to complete the installation. VSIX packages are available here, as well as from the Visual Studio Extensions Gallery accessible directly from VS.
  • Since VS integration is on a per version basis, this new model also supports simultaneous installations of multiple VS versions.



#60173 Where are the COM ports located on the board?

Posted by CW2 on 21 September 2014 - 06:35 PM in Netduino Plus 2 (and Netduino Plus 1)

You'd need Cadence Allegro Viewer to view the brd file, it has different format and is not supported by Eagle. You can view the pin assignment in the schematics (pdf).




#60125 Building custom Netduino Mini

Posted by CW2 on 16 September 2014 - 08:55 AM in Netduino Mini

To get some ideas, have a look at the schematics (pdf, from the downloads page), there is also board file (for Cadence Allegro Viewer, does not work in Eagle). The microcontroller is AT91SAM7X512-CU.
 
However, AT91SAM7 is rather old and there is no 4.3 firmware - you might want to consider a more recent microcontroller, such as Cortex-M3/M4, which are very popular.
 
Community member Juzzer has done some amazing work regarding custom designed boards, also see his posts in GHI forums.



#60045 USB power vs. input power

Posted by CW2 on 09 September 2014 - 11:18 AM in Netduino Plus 2 (and Netduino Plus 1)

If I use an external power supply with 5V and connect it through the Micro USB port, will it provide sufficient power to the netduino including all pins (PWM, ...)?


Yes.
 

I can't find any available industrial power supplies with 7.5 - 9V

 

You don't need an industrial grade power supply, a wall adapter is sufficient.

 

I guess I can't use 5V input on the power socket?

 

No, the onboard linear regulator requires at least ~6.5 V input.




#60025 AT91_GPIO.cpp

Posted by CW2 on 07 September 2014 - 08:03 PM in Netduino Plus 2 (and Netduino Plus 1)

This mean AT91_GPIO is using for firmware(porting kit) and using for SDK(secret labs), too?

 

Not really. There are four parts:

  1. .NET Micro Framework Porting Kit
  2. Netduino firmware source by Secret Labs
  3. .NET Micro Framework SDK
  4. Secret Labs SDK (for Netduino boards)

AT91_GPIO.cpp is in 1. and 2. - these two parts you need to build the Netuino firmware. Install the .NET MF Porting Kit, download Netduino Firmware source zip and extract it over Porting Kit, overwriting the files.

 

.NET MF SDK (3.) must be installed to have .NET MF project support in Visual Studio and you also need Secret Labs SDK (4.) to have assemblies (.dll) and project templates for Netduino.

 

Excuse me, I don’t know about .obj file! Can you explain about it?

 

C/C++ source file is compiled into OBJ file, which is then linked with the rest of OBJ files and libraries into final executable, in this particular case (microcontroller) the 'executable' is in ELF format, which is then transformed into HEX (resp. SREC) or BIN suitable for flashing.

 

I don’t know where to start and which files should be changed!

 

Try searching the forum and wiki for 'building firmware' or such, it has been discussed numerous times. You'd need the source code, an ARM Toolchain and a lot of patience - 4.1 is rather old...




#60020 AT91_GPIO.cpp

Posted by CW2 on 07 September 2014 - 05:59 PM in Netduino Plus 2 (and Netduino Plus 1)

It is in DeviceCode\Targets\Native\AT91\DeviceCode\AT91_GPIO folder. There are two versions: the original included in .NET Micro Framework Porting Kit and the one with Secret Labs modifications in the Netduino firmware source archive.
 

Has this change an affect on another files?

 

Well, it depends on the change. It is possible to change a C++ source file in a way that it does not affect the generated .obj file (e.g. adding a comment).

 

What steps are necessary to make this change?

 

Open the .cpp file in your favorite text editor...  :P

 

But I guess there is something else - what exactly do you want to achieve? Does it involve building the firmware?




#59997 Windows on Devices? When?

Posted by CW2 on 05 September 2014 - 06:09 AM in General Discussion

Well arduino still doesn't have RTOS, Threading or whatever...

 

Not from my own experience, as I don't use RTOS on any Arduino, but quick check reveals that ChibiOS, BeRTOS, FreeRTOS support AVR (and there is about 40 more in the Wikipedia list that mentions AVR).




#59984 Safe code to convert byte[4] to float

Posted by CW2 on 04 September 2014 - 06:19 AM in General Discussion

The BitConverter class was added in .NET Micro Framework 4.3.




#59975 Analog Input Limits

Posted by CW2 on 03 September 2014 - 06:16 AM in Netduino Plus 2 (and Netduino Plus 1)

The easiest way to measure 5 V on 3.3 V analog input is to use a voltage divider. For precise measurements I think you'd need to use an external specialized IC (ADC) that communicates via a digital interface such as I2C or SPI.

 

Notes:

  • Netduino cannot measure voltage higher than analog reference (Aref), which is limited to operating voltage, which is 3.3 V.
  • Netduino 2 analog inputs are not 5 V tolerant, the absolute maximum allowed input voltage is 4 V.



#59936 Maximum port frequency ...

Posted by CW2 on 29 August 2014 - 01:21 PM in Netduino Go

So, I'm not going to be able to create any kind of radio signal by toggling a port on the Netduino ... at least not in the amateur bands (2 meter band). That would require about 145 MHz.

 

You should have mentioned that in the original post - Shield Base has STM32F205 microcontroller that runs at 120 MHz, Netduino Go STM32F4 at 168 MHz. So, not enough for 145 MHz pin toggling even when done in assembly...




#59916 Convert Arduino Library To Netduino

Posted by CW2 on 27 August 2014 - 02:02 PM in General Discussion

Unfortunately, I don't have any MAX7219, but it seems to be fairly easy to operate the cascade:

  • Connect all LOAD/!CS inputs together (to Netduino pin used as SPI CS),
  • Connect MAX DOUT to DIN to chain the devices.
[Netduino] MOSI -> DIN [ Max#1(16 bits)] DOUT -> DIN [Max#2(16 bits)] DOUT -> ...
           CS ------------- LOAD/!CS ------------------- LOAD/!CS

Note: The clock (SPI CLK) signal is omitted for sake of brevity, it must be connected together.

That means the cascade behaves like one N×16 bits register. So, when you send 16 bits to the first Max#1, the contents of its internal 16 bit register is shifted out to the adjacent device, whose contents is shifted out to the adjacent device (if any) etc. (you can connect DOUT to Netduino MISO and you can receive the data back, which is often useful - this way you can detect the number of  chained devices in runtime).
 
To operate the cascade, you simply send N×16 bits of data (N×2 bytes) and control all MAX ICs at once. If any of the 16 bits have address zero, i.e. the NO-OP command, the corresponding MAX does nothing and appears as skipped - which enables you to control only selected device(s).
 

var maxChain = new SPI(new SPI.Configuration(...));
var numberOfDevices = 2;

var data = new byte[numberOfDevices*2];
// Important note: The following order is most likely wrong,
// too lazy to think about it...
data[0] = 0x01; // Max#2 Data
data[1] = 0x0F; // Max#2 Address
data[2] = 0x00; // Max#1 Data
data[3] = 0x00; // Max#1 Address

maxChain.Write(data);



#59914 Convert Arduino Library To Netduino

Posted by CW2 on 27 August 2014 - 07:08 AM in General Discussion

Well, how should I put this... the whole LedControl code is basically one SPI.Write() method call to transfer 16 bit data (spiTransfer() function) to the MAX and a few methods that set the data to perform the desired command.
 
Personally, I would stop converting the Arduino code and start with C# from scratch, using the device datasheet as reference and the Arduino code if in doubt (assumed to be working). There is also possibility that the converted code will not work at the first try, so you'd need to troubleshoot it, and it is much easier to troubleshoot code you understand well (e.g. written yourself).
 
Create a new project and start talking to the MAX using the SPI class, it should be something like this: 

...
public static void Main()
{
  var max = new SPI(new SPI.Configuration(...));
  var data = new byte[2]; // 16 bits (address + 8 bit data)

  // Display test mode
  data[0] = 0x0F; // Address
  data[1] = 0x01; // Test mode on

  max.Write(data);

  Thread.Sleep(Timeout.Infinite);
}

Once you get the code working (written from head, so probably does not even compile, data buffer can be ordered the other way round etc.), you can add command constants and wrapper methods, then you will be able to use the Arduino code because you'll see what it does and where it fits.




#59907 Convert Arduino Library To Netduino

Posted by CW2 on 26 August 2014 - 04:18 PM in General Discussion

Now I am getting a bunch of "the name ______ does not exist in the current context."

 

Well, those are Arduino library function calls and some constants - the good news is you don't need to convert that, just implement spiTransfer() function to call .NET Micro Framework SPI.Write() method and delete all pinMode(), digitalWrite() etc. calls, which are not needed (because SPI class does that internally; including the ChipSelect pin if you set it in the configuration).




#59902 Convert Arduino Library To Netduino

Posted by CW2 on 26 August 2014 - 06:32 AM in General Discussion

The name 'B01111110' does not exist in the current context

 

C# does not support binary literals - you'd have to either define those Bxxx constants like

 

const byte B01111110 = 0x7E;

const byte B00110000 = 0x30;

...

 

or use the hex literals directly, i.e. instead of B01111110 write 0x7E.




#59897 LLVM Based Optimizer for MSIL

Posted by CW2 on 25 August 2014 - 05:20 PM in General Discussion

There is one very interesting comment (the first one) for channel9 Visual Studio Team Interview Fun with the Interns: Santiago Fernandez on LLVM Based Optimizer for MSIL, which mentions SharpLang - a .NET (MSIL) compiler front-end for LLVM. Has anyone had a chance to play with it already? Any thoughts?




#59870 Convert Arduino Library To Netduino

Posted by CW2 on 24 August 2014 - 03:15 PM in General Discussion

OK, got LedControl.cs to pass compile, except for 12 errors. They are:

Type 'Dome_Controller_Arduino_Port.LedControl' already defines a member called 'LedControl' with the same parameter types

 

You have left empty function declarations in your C# class - this is valid in C/C++, where you can have empty function declaration (in .h) and then implement in at different place (.cpp), but not allowed in C#. Delete all empty functions at the beginning of the C# file, where you have the class declaration from C++ header.




#59798 Windows on Devices? When?

Posted by CW2 on 20 August 2014 - 03:50 PM in General Discussion

Running a simple .NET console app on the Intel Galileo with Windows by Pete Brown




#59790 ISR in interop

Posted by CW2 on 20 August 2014 - 06:42 AM in Netduino Plus 2 (and Netduino Plus 1)

Default PK use GPIO ISR handler for checking out the stream on usart. I will test and share results.

 
Well, not really - STM32F4 firmware uses USART interrupt handlers, see STM32_usart_functions.cpp:

CPU_INTC_ActivateInterrupt(g_STM32_UART_Irq[uartNum], STM32_USART_Interrupt0, 0);

GPIO ISR is used in STM32_GPIO_functions.cpp to handle pin interrupts, does not do anything with USART.




#59789 ISR in interop

Posted by CW2 on 20 August 2014 - 06:32 AM in Netduino Plus 2 (and Netduino Plus 1)

But my code is confirmed in native project(Keil), now I'm finding the problem.

 

When you use your ISR handler, have you disabled/removed the one in the firmware? There will be a conflict - .NET Micro Framework does not have any support for hardware resource sharing/management, so one must be a little bit careful when adding custom functionality.

 

Also, there are some things you have to add to your native code (which works in Keil) to make it work correctly in .NET Micro Framework - such as properly reserve the pins, use lock macros, etc.




#59786 ISR in interop

Posted by CW2 on 19 August 2014 - 06:29 AM in Netduino Plus 2 (and Netduino Plus 1)

You should be able to hit a breakpoint in an ISR handler - if you can't, it can indicate it is never called (do you actually activate/enable it in your code?).

 

What version of Netduino do you have? Are you developing a port for a new microcontroller? There is already USART ISR handler implemented in the firmware - you can use it as a reference for things needed to get it work (e.g. configure pins, enable peripheral clock, activate interrupt, setup USART module, use locks etc.).





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.