Author Topic: VIN not working?  (Read 13526 times)

NeuroJoe

  • Newbie
  • *
  • Posts: 11
VIN not working?
« on: August 30, 2014, 09:00:01 pm »
Hi all, I'm pulling my hair out tonight (or at least what's left of it). I'm working on a project that involves multiple breadboarded Digisparks. I was having a hard time making sense of why outputs were or weren't being activated when they should be, so I simplified it by working with one at a time now. For at least 2 of the 8 sparks ( I haven't tested the other 6 yet), I seem to be having a problem with my VIN. When I power the spark over USB, the sketch runs fine, and pin 0 outputs as it should. I've tested it with an LED and my multimeter, and I get 4.70 volts. When I power it with a 12V NiMH 2.1A battery (which is outputting 12.9V per the multimeter) hooked up to the VIN pin, and the ground from the battery to the ground pin, the multimeter is telling me that I'm getting no output from pin 0. One interesting thing is that the green power LED does come on when VIN power is applied (to both of the 2 I tested), but the sketch doesn't appear to be running. The sketch is definitely uploaded to the spark, because I test this serially, first with USB power but not transferring the sketch again, and then with VIN power. I will go through and test the others (I bought 10 total), but I just wanted to check in and make sure I'm not doing something wrong here. The sketch is pasted below, I've commented out some things during testing but the important code is at the bottom showing pin 0 and pin 1 turned to HIGH. Thoughts?

TIA,

Joe

//Inhibitory Endogenous Burster
//Cell A or B

 #include "DigiKeyboard.h"
 
  int cell1 = 1; //digital pin 2
  int cell1Raw = 0;
 int cell1Scaled = 0;
  int avgScaled = 0;
 int internalState; //value output to the PWM (analog out)
  float sinVal;   
  const int taOut = 0;
  const int ebOut = 1;
  int outputLevel;
  int IPSP = 0; //IPSP gives synaptic weight of 0
  int noInput = 50;

 
 
 
void setup(){
 
     //P0, P1, and P4 are capable of hardware PWM (analogWrite).
    //pinMode(0, OUTPUT); //0 is P0, 1 is P1, 4 is P4 - unlike the analog inputs,
                        //for analog (PWM) outputs the pin number matches the port number.
   pinMode(taOut,OUTPUT); //digital pin 0; to tonically active A cell
   pinMode(ebOut, OUTPUT); //digital pin 1; to other endogenous burster cell
}

void loop(){


  for (int x=0; x<180; x++) {
        sinVal = (sin(radians(x)));
        internalState = int(sinVal*255); //pwmVal is internal state of endogenously bursting cell
       
DigiKeyboard.print("SinVal=");
DigiKeyboard.println(sinVal);
DigiKeyboard.print("Output voltage to TA cell=");
DigiKeyboard.println(outputLevel);
DigiKeyboard.print("Output voltage to EB cell=");
DigiKeyboard.println(outputLevel);
DigiKeyboard.print("Input voltage="); //from SFA cell a or b
                                       //should map to realistic voltages
 DigiKeyboard.println(cell1Scaled);
 DigiKeyboard.print("Resting State="); //print initial state of the cell
 DigiKeyboard.println(internalState);
 DigiKeyboard.print("Mean voltage=");
 DigiKeyboard.println(avgScaled);

                                     
cell1Raw = analogRead(cell1);// input from SFA cell a or b
   cell1Scaled = (cell1Raw / 4);


  avgScaled = ((cell1Scaled + internalState) / 2); // calculate the average voltage of the 2 inputs and put it in avgScaled
       

  /*if (avgScaled > 10) //set threshold to 10
  {
  outputLevel = IPSP; //inhibitory neuron activation leads to IPSP and synaptic weight of 0
  }
 
  else
  {
    outputLevel = noInput;
   {
     */
     outputLevel = 255;
 analogWrite(taOut, outputLevel);
analogWrite(ebOut, outputLevel);

 
   }}

Andriod

  • Newbie
  • *
  • Posts: 6
Re: VIN not working?
« Reply #1 on: October 29, 2014, 06:48:47 pm »
I'm seeing the same thing.  I have LEDs on P1-P5 and a sensor on P0.  When I run on USB my sketch uses the sensor to tell when to run a light show.

On a 9V battery connected to GND and VIN all I get is the light on P5 turned on.  I was thinking it was because of that being a reset pin, but why is this a problem only on battery?

Did you ever solve your issues?

Andriod

  • Newbie
  • *
  • Posts: 6
Re: VIN not working?
« Reply #2 on: October 30, 2014, 06:09:23 pm »
I'm wondering, I accidentally punched the burn bootloader option on the IDE, could that have caused this somehow?  It seems like a long shot, but it's a weird behavior by any measure.

NeuroJoe

  • Newbie
  • *
  • Posts: 11
Re: VIN not working?
« Reply #3 on: November 11, 2014, 09:46:26 am »
No I'm still getting the problem, it's been difficult to diagnose exactly what's going wrong. It sure seems like the spark runs fine on 5V directly from USB but 12V through the VIN pin doesn't allow the sketch to run properly. I'm waiting on my Pro order to see if those have the same behavior or not.

Andriod

  • Newbie
  • *
  • Posts: 6
Re: VIN not working?
« Reply #4 on: November 11, 2014, 10:34:18 am »
Anyone successfully power a spark with a 9V battery?

DeuxVis

  • Full Member
  • ***
  • Posts: 107
Re: VIN not working?
« Reply #5 on: November 13, 2014, 12:49:34 am »
Yes just do something like this.

The 2 cables on the right are optional, just a commodity to give you access to the 5V provided by the digispark's regulator on the top rail.

Andriod

  • Newbie
  • *
  • Posts: 6
Re: VIN not working?
« Reply #6 on: November 13, 2014, 06:15:03 am »
yep, that's what I did.  Did it work for you when you tried it?  I'll try to swapping out the spark, but it's already soldered in so I haven't been looking forward to that.

NeuroJoe

  • Newbie
  • *
  • Posts: 11
Re: VIN not working?
« Reply #7 on: November 13, 2014, 08:04:23 am »
Yeah, what Android said. Conceptually I understand the VIN should work that way, but when you actually try it, 12V (or 9V I guess) doesn't power the Spark properly. I can load a sketch and run it over 5V USB just fine. When i unhook the USB cable and run 12V to the VIN pin, no dice, my test LED doesn't light like it does on 5V through the 5V pin. I've tried multiple Sparks and they all seem to have this problem. I'm going to try a regulated 5V supply run off of a 9V wallwart next, hopefully that gives better results.

exeng

  • Sr. Member
  • ****
  • Posts: 454
Re: VIN not working?
« Reply #8 on: November 13, 2014, 08:55:29 am »
I have a Digispark running off battery power that provides the brains to control a hacked digital camera to do time lapse photograpghy. Unfortunatley I'm away from the circuit board rigth now but if I had to guess, I probably have a 7805 regulator before VIN. As soon as I can get back to it (perhaps as early as tomorrow) I will will provide my info on how things are wired.

NeuroJoe

  • Newbie
  • *
  • Posts: 11
Re: VIN not working?
« Reply #9 on: November 13, 2014, 10:37:08 am »
I suspect the lack of a regulator is the problem I'm having, now that I think more about it. After reading up on the small form factor Arduinos like the mini and micro, they both have a RAW pin that takes unregulated (battery) power, and a VIN pin that takes voltage above 5V but from a regulated supply. Since Android and I are both trying to run the Sparks off of unregulated power through the VIN pin, our similar problem may be more than a coincidence. I've got a regulated supply showing up soon so I can test this hypothesis.


NeuroJoe

  • Newbie
  • *
  • Posts: 11
Re: VIN not working?
« Reply #10 on: November 15, 2014, 09:44:08 am »
More strange behavior to report. I have a test sketch loaded to the Sparks that should cause an LED to fade up and down due to a half sine wave function output function in the sketch. A regulated 5V output (measuring 4.96V on my multimeter) does not allow the sketch to run on the Spark. However, if I start the sketch by powering the Spark over USB, the LED will fade up and down as it should. If I then plug in the regulated 5V supply (so both USB and regulated 5V are plugged into the + rail on the breadboard) , the sketch continues to run as normal. If I unplug USB power, the LED does NOT go out, but it halts the fading at the current output level. So in effect, the sketch stops looping, but does not shut off.  :o From what I remember, I saw this same behavior with a 12 battery into the VIN pin instead of the regulated 5V supply into the 5V pin. Now I think I see why the company is called Digistump, because I'm stumped.


Joe

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: VIN not working?
« Reply #11 on: November 15, 2014, 12:45:13 pm »
The VIN pin feeds the regulator (the biggest chip on the board) - and if you give it 9v it should spit out 5v on the 5v pin without any issue.

Joe - can you tell me where you Digispark was purchased from? And how many you have seen this behavior on. It sounds like the main MCU is defective.  I run them on 9v all the time - without ever an issue (except when the battery runs dead).

exeng

  • Sr. Member
  • ****
  • Posts: 454
Re: VIN not working?
« Reply #12 on: November 15, 2014, 12:47:45 pm »
OK, I checked my time lapse circuit and I am definitely feeding VIN from a 7805 with a .33uf cap on the input side and a .1uf cap on the output side. Since I am also driving 5v relays (3) I'm powering everything (including the Digispark) with a 9v battery pack made up of 6 C cell batteries but I have also run this off of a 9v battery the same way, through my 7805 regulator.

exeng

  • Sr. Member
  • ****
  • Posts: 454
Re: VIN not working?
« Reply #13 on: November 15, 2014, 12:51:18 pm »
It occurred to me that I could easily run the Digispark off a 9v battery unreg through VIN while running the relays off the regulated power to see if the Digispark will run. Let me know if you would like me to conduct this test.

NeuroJoe

  • Newbie
  • *
  • Posts: 11
Re: VIN not working?
« Reply #14 on: November 15, 2014, 02:59:41 pm »
The VIN pin feeds the regulator (the biggest chip on the board) - and if you give it 9v it should spit out 5v on the 5v pin without any issue.

Joe - can you tell me where you Digispark was purchased from? And how many you have seen this behavior on. It sounds like the main MCU is defective.  I run them on 9v all the time - without ever an issue (except when the battery runs dead).

I bought 10 of them from your online store. They've all exhibited this behavior, which makes me wonder if it's something I'm doing wrong, but I don't see what it could be. The header pins seem to be soldered on ok because the green power LED lights up over USB, 5V or VIN power just fine, but the sketches only run over USB supplied 5V.