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.

FVN.Net's Content

There have been 15 items by FVN.Net (Search limited from 11-April 19)


By content type

See this member's

Sort by                Order  

#36596 I²C connection with RFID - revisited

Posted by FVN.Net on 05 October 2012 - 09:28 PM in Netduino Plus 2 (and Netduino Plus 1)

Sorry dear forum members that I repeat my earlier question here in the N+ department.
The original posting of the problem is here:
http://forums.netdui...tion-with-rfid/

I know that this double posting isn't good practice but when browsing the VB.Net part of the forum, I noticed that the topic I²C came up in the dedicated VB pages 3 or 4 times over the past months with no answer at all or just a vague code snippet at best. So I take my chance again by posting it on the N+ pages, which seem to be read and replied to more.

VB support is what brought me to Netduino so I'd really like to get my project going. It's been over three days and numerous hours of trying to get something into /out of the SL030 RFID reader over I²C.

Here's my code:
Dim cfg As New I2CDevice.Configuration(80, 100)
Dim iic As New I2CDevice(cfg)

Dim outbytes() As Byte = New Byte() {}
Dim inbytes() As Byte = New Byte(7) {}

Dim i As Integer = 0
Dim sInput As String = ""

outbytes = New Byte() {80, 1, 1}

Dim write_transaction As I2CDevice.I2CTransaction = I2CDevice.CreateWriteTransaction(outbytes)
Dim read_transaction As I2CDevice.I2CTransaction = I2CDevice.CreateReadTransaction(inbytes)

Dim transActionList As I2CDevice.I2CTransaction() = New I2CDevice.I2CTransaction() {write_transaction, read_transaction}

i = iic.Execute(transActionList, 10)
Debug.Print(i.ToString)
Thread.Sleep(50)
For Each item As Byte In inbytes
   sInput &= item.ToString & " "
Next
Debug.Print(sInput)

This code tells me that 3 bytes have been sent as expected (outbytes array) and that nothing comes into the inbytes array since it all remain bytes set to zero by the declaration of the array.

Right now there are no external pull ups engaged, since WITH pull ups I get '1' for bytes sent and WITHOUT I get the expected 3 bytes sent.

I've searched everywhere and have tried numerous things. It drives me crazy.
I'd be really grateful if someone could help me out? Thanks a lot!
- Franki



#36493 I²C connection with RFID

Posted by FVN.Net on 03 October 2012 - 07:06 PM in Visual Basic Support

I made a new topic to abandon the old (here) since I feel I made some progress.

I tried to write 'native' VB code for my I²C connection, so not using any custom class or wrapper like the Toolbox. Here's what I came up with:

Dim outbytes() As Byte = New Byte() {}
Dim inbytes(6) As Byte '= New Byte() {}

Dim cfg As New I2CDevice.Configuration(80, 400)
Dim iic As New I2CDevice(cfg)

outbytes = New Byte() {160, 1, 1}

Dim write_transaction As I2CDevice.I2CTransaction = I2CDevice.CreateWriteTransaction(outbytes)
Dim read_transaction As I2CDevice.I2CTransaction = I2CDevice.CreateReadTransaction(inbytes)
Dim transActionList As I2CDevice.I2CTransaction() = New I2CDevice.I2CTransaction() {write_transaction, read_transaction}

Dim i As Integer = iic.Execute(transActionList, 5000)

The good thing is: this code does NOT result in an error. It seems the array that will contain the read bytes should have a fixed size. That makes sense, in retrospect. So after defining the size of this array, the exception was gone.

The bad thing is: the inbytes array is not filled with valid data but stays filled with zeroes.
FWIW, the device I'm trying to interface with is here (RFID reader).

EDIT after 2 hours of more testing and trying.
This line of code:
Dim i As Integer = iic.Execute(transActionList, 1000)[/code]

returns 1 WITH 10k or 2k2 pull ups
returns 3 WITHOUT these pull ups.
I'd say 3 is correct because of 3 items in outbytes. The inbytes array does not change, unfortunately.

Any clues?
- Franki



#36461 Send Bytes over I2C.

Posted by FVN.Net on 03 October 2012 - 02:06 PM in Visual Basic Support

Thanks but this doesn't get me any further. Does the '80' only apply to the address or also to the command byte?

This gives an error:
outbytes = New Byte() {80, 1, 1}
                IIC.WriteRead(outbytes, inbytes)
And this too:
outbytes = New Byte() {161, 1, 1}
                IIC.WriteRead(outbytes, inbytes)

If I split up the reading from the writing, I get beyond this just fine:
outbytes = New Byte() {80, 1, 1}
                IIC.Write(outbytes)

But then the exception is thrown right after when I try to read into 'inbytes':
A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
Exception was thrown: System.ArgumentException

So it seems it goes bad when reading.

My problem is A) being new to Netduino and embedded in general, B ) never used I²C and C) not familiar with this particular device (RFID reader).
This means a lot of unknowns in the equation, and I don't know how to code up I²C straight from the µF in VB. Is my VB code bad or do I just send or expect the wrong things from the slave device?

For point B I try to use the Toolbox I2C-helper but I'm doing something wrong obviously.
For point C here's the device (+datasheet): http://www.stronglin...ules/sl030.html

I found some assembler-ish or C-like code samples to interface this device over I²C and hoped to understand it and 'translate' it to my needs but I must admit I don't really get what I'm seeing.

I'm hoping someone out here could show me the way or guide me through the learning process? I'd really appreciate that.
- Franki

EDIT: opened a new topic for this HERE since I think I made a breakthrough.



#36440 Send Bytes over I2C.

Posted by FVN.Net on 03 October 2012 - 07:20 AM in Visual Basic Support

As a coincidence, I was trying about the same thing last night - and failed!
I'm trying to read the card ID from an RFID reader through I²C.

Here's my code:
Dim IIC As New MultiI2C(161, 100)
    Dim outbytes() As Byte = New Byte() {}
    Dim inbytes() As Byte = New Byte() {}
    
    outbytes = New Byte() {161, 1, 1}
    IIC.WriteRead(outbytes, inbytes)

I made an event handler based on the 'card detected' output, fed to an input. This works fine.
The last 2 lines of code are in the interrupt / event handler because it only makes sense to talk to the reader when a card is detected.

And here's where it crashes:
"A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll
Exception was thrown: System.ArgumentException"

Why 161: the datasheet says I need a 7 bit address (default = 80), and the 8th bit (LSB) should be '1' to read.
That gives: 10100001 = 161.

Why {161, 1, 1}: the specs say:
  • Address: 1 byte, 0xA0
  • Len: Byte length counting from Command Code to the last byte of the data, 1 byte.
  • Command: Command Code, 1 byte.
  • Data: Data, variable length depends on the command type.
So read from address 80 = 161, 1 byte length, command = 1

The question is: do I use the VB code in a wrong way, or don't I understand the specs of the I²C protocol?
I can't find any useful information online that combines N+ with VB and I²C. So I need to turn to this forum once again for help...

HELP! :wacko:
- Franki



#36439 Using Adafruit RGB LCD Shield (I²C)

Posted by FVN.Net on 03 October 2012 - 06:56 AM in Netduino Plus 2 (and Netduino Plus 1)

I finally got to test it and yes it sure works! :D Thanks!



#36185 Using Adafruit RGB LCD Shield (I²C)

Posted by FVN.Net on 28 September 2012 - 03:03 PM in Netduino Plus 2 (and Netduino Plus 1)

"Just checking" - and keeping fingers crossed. I'm about to finish the assembly of the I²C driven LCD + buttons from Adafruit (RGB LCD Shield I²C). To use it, can I just connect +5V/GND and SCA/SCL to the right pins on the N+ and their pull-ups (10k?) and run/modify the module "Adafruit RGB LCD Shield" from the NetMFToolbox? Could that be all? Connect and use the Write and ChangePosition methods? Or am I overlooking something? I know classic electronics and am a self-taught VB.Net programmer, but this N+ stuff is all new to me, and I have so many things in mind I want to do with it. - Franki



#35642 Problem using AnalogInput

Posted by FVN.Net on 20 September 2012 - 08:30 PM in Netduino Plus 2 (and Netduino Plus 1)

Kem, PROBLEM SOLVED!

I just installed 'Version: 4.2.0 Update 1 (version 4.2.0.1)' of the firmware, I was still running 'NetduinoPlus_4.2.0.0_RC5' which I believed to be the most recent but it turned out Chris W published an update note yesterday. My bad! :huh:

My led is now blinking to the value of the potmeter. Finally!

Is there an online document or resource where I can get an overview of the most used classes for I/O (RS-232, I2C, SPI, PWM etc)? I'd love to learn more without having to ask too many questions, like I try to solve my Win Forms programming problems.

Thanks again for all your help!
- Franki



#35616 Problem using AnalogInput

Posted by FVN.Net on 20 September 2012 - 06:05 PM in Netduino Plus 2 (and Netduino Plus 1)

Dear Kem, I really appreciate your time and effort, but all your hints don't work for me (so far).
I opened a totally new solution from scratch. Even one single line of code causes the program to break:

Imports Microsoft.SPOT
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus

Module Module1
    Sub Main()
        ' write your code here
        Dim potMeter As New AnalogInput(AnalogChannels.ANALOG_PIN_A1)
    End Sub
End Module

An attached PNG shows my references.
I just don't get it, it's always 'An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll'and the execution breaks.

I wrote a button-lights-led program that works so it's really the AnalogInput part that bothers me.

- Franki

Attached Thumbnails

  • AnalogInput_refs.png



#35603 Problem using AnalogInput

Posted by FVN.Net on 20 September 2012 - 04:31 PM in Netduino Plus 2 (and Netduino Plus 1)

Too bad Kem, still the same problem:

Imports Microsoft.SPOT
Imports Microsoft.SPOT.IO
Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus
Imports System.IO

Module Module1
    Sub Main()
        Dim potMeter As New Microsoft.SPOT.Hardware.AnalogInput(AnalogChannels.ANALOG_PIN_A0)
        For i As Integer = 1 To 50
            Debug.Print("Value: " & potMeter.Read().ToString())
        Next
    End Sub
End Module

results in: "A first chance exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll"

If I change the line of code to
Dim potMeter As New AnalogInput(AnalogChannels.ANALOG_PIN_A0)
I get:
" 'AnalogInput' is ambiguous, imported from the namespaces or types 'SecretLabs.NETMF.Hardware, Microsoft.SPOT.Hardware'. "

The project references show version 4.2.0.1 only for SecretLabs.NETMF.Hardware.NetduinoPlus and SecretLabs.NETMF.Hardware.AnalogInput, yet 4.2.0.0 for ALL other DLLs including SecretLabs.NETMF.Hardware.

I have no clue how to get this simple thing going...
- Franki



#35584 Problem using AnalogInput

Posted by FVN.Net on 20 September 2012 - 10:20 AM in Netduino Plus 2 (and Netduino Plus 1)

Imports Microsoft.SPOT.Hardware
Imports SecretLabs.NETMF.Hardware.NetduinoPlus

Dim potMeter As New AnalogInput(AnalogChannels.ANALOG_PIN_A0)


Thanks Kem, but I still get an error when trying to execute the code. The code breaks on that line.

- Franki



#35545 Problem using AnalogInput

Posted by FVN.Net on 19 September 2012 - 07:52 PM in Netduino Plus 2 (and Netduino Plus 1)

Hello to all

For the first time I try to use an analog input on my N+ with latest firmware.

I tried the obvious:

Dim potMeter As New AnalogInput(Pins.GPIO_PIN_A0)
but this gave me:
Option Strict On disallows implicit conversions from 'Microsoft.SPOT.Hardware.Cpu.Pin' to 'Microsoft.SPOT.Hardware.Cpu.AnalogChannel'.

This link told me to use this line of VB code:
Dim potMeter As New Microsoft.SPOT.Hardware.AnalogInput(Cpu.AnalogChannel.ANALOG_0)
or
Dim potMeter As New SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0)
results in this error:
An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.SPOT.Hardware.dll

So I can't even run my code, it breaks when initialising the analog input.
What am I doing wrong? What am I overlooking? All help appreciated. Thanks already.



#33226 freeware Virtual COM port for SAMBA?

Posted by FVN.Net on 07 August 2012 - 03:10 PM in Netduino 2 (and Netduino 1)

SAM-BA is the normal tool for this, and is free. I didn't even knew there were non-free tools for that purpose?
The driver comes with SAM-BA.


Strange - I had Samba 2.11 and just installed 2.12 but Samba doesn't find its own COM-port then (other than the odd occasion earlier today). I had to install (and will have to again) another software and select these COM ports in Samba. There are no COM ports listed in my PC's hardware tree.


The 4.2 firmware for Netduino and Netduino plus is still beta and I know of this issue. I hope the next RC (or RTM) will have this fixed, but I can 'comfort' you by telling you're not the only one experiencing that issue :)


OK, fingers crossed then. The full reset is not a real problem once you know the procedure. It's just that after the evaluation period expires, I need to find another virtual COM port package. I wonder what's wrong with Samba then and why it did work but only once this morning...



#33224 N+ loses IP info

Posted by FVN.Net on 07 August 2012 - 02:39 PM in Netduino Plus 2 (and Netduino Plus 1)

Hi and welcome to the forums!


Thank you, I hope to one day answer more than have ever asked...

Two quick questions:
1. Which firmware do you use?


Version: 4.2.0 RELEASE CANDIDATE (version 4.2.0.0 RC5)

2. Have you commented out this line from that project?

Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableDhcp();


No -shame on me- I did not and thus fell into the common copy/paste trap. I moved the server code into a separate class and kept this line in Sub Main where I never looked back. Problem fixed, on to the next one.

Thanks for the quick reply!



#33218 N+ loses IP info

Posted by FVN.Net on 07 August 2012 - 01:28 PM in Netduino Plus 2 (and Netduino Plus 1)

I hope this is a common newbie problem although a quick search doesn't reveal a solution. Using MFDeploy I set my N+ to 10.1.1.10 / 255.0.0.0 / DG = 10.1.1.1. No DHCP. I ping from the laptop and it sees the N+. So far so good. In VS2010, I have ported this code to VB: http://netduinohacki...ello-world.html THIS HAS WORKED A COUPLE OF TIMES from the start but it fails to do so now. However, the code is ok since it works from the browser and also replies to my own Windows Forms program. The code GetAllNetworkInterfaces()(0).IPAddress gives 10.1.1.10 when it works but 0.0.0.0 when it doesn't. After this trial, a ping doesn't show the N+ anymore, so I need to run MFDeploy again. Somewhere it has set the N+ to DHCP and since there is no DHCP, all IP's are 0. When the IP info is set again, running the code sets DHCP to 'on' and IP's to 0.0.0.0. Can someone please explain what might be the problem? All input appreciated!



#33216 freeware Virtual COM port for SAMBA?

Posted by FVN.Net on 07 August 2012 - 12:03 PM in Netduino 2 (and Netduino 1)

Does anyone know if there is a freeware virtual com port driver to use with Atmel's Samba to install the TinyBooterDecompressor? I've used two freeware programs which work great but are limited in time and a license key is pretty expensive. Any hints? Also on one occasion Samba found a USB com port (on board the Netduino?) which worked too. But I cannot reproduce this. Can someone tell me what's up with this? Thanks in advance! For some reason my netduino+ seems to be totally frozen quite often, even MFDeploy can't connect to it which only leaves me the 'hard reset' option. Since I'm a beginner, it might be an operator error of course. Using µFW 4.2 for VB in VS2010.




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.