E-MotorWerks JuiceBox - an open source 15kW EVSE

My Nissan Leaf Forum

Help Support My Nissan Leaf Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Raycreed said:
I sent emotorwerks an e-mail, maybe they can tell me something I don't know.

I am an OpenEVSE guy too and don't know too much about Juicebox... But it kinda sounds like your unit thinks it is on L1 and is maxing out the pilot at 16A. I do not know how the L1/L2 detection works on Juicebox but I have read that on L1 it is a fixed value and L2 uses an analog pot for adjustment.
 
chris1howell said:
It kinda sounds like your unit thinks it is on L1 and is maxing out the pilot at 16A. I do not know how the L1/L2 detection works on Juicebox but I have read that on L1 it is a fixed value and L2 uses an analog pot for adjustment.

That's a likely suggestion. There are some notes below for tweaking necessary on an 8.1 board.
Ray, can you read the A1 pin on your juicebox both while charging and while not charging and follow the instructions below?
Or, since its your box and you're free to do what you want. Just go to the line in the code where read_V is called and set it to a constant 240. Problem solved. Your box will simply no longer automatically detect 120 anymore, so stick a piece of masking tape to the box noting this so you don't forget.

Hope it works.

Code:
// read the average input AC voltage 
// this function should ONLY BE CALLED in setup()
// time constant of the RC filter: 27k * 3.3uF = ~0.09s - enough to smooth 60Hz signal
float read_V() {
  float V_AC=240; // default is 240
  
  float V_Ard_pin=analogRead(pin_V)*Aref/1024.;
  delay(8); // measure 180 degrees away by AC phase to smooth out any remaining ripple on A1 pin
  V_Ard_pin+=analogRead(pin_V)*Aref/1024.;
  V_Ard_pin/=2;
  
#ifdef PCB_81
  // for PCB versions before 8.3, 
  // THIS FEATURE IS IN BETA AND MAY NOT WORK ON THE FIRST VERSION OF THE BASE BOARDS WITHOUT TWEAKING FIRMWARE
  // specifically, you may need to tweak the voltage threshold between 120V and 240V input voltage 
  //   (line starting with 'if(V_Ard_pin >' below). (1) connect JuiceBox to 120V, measure the voltage on pin A1 of the Arduino
  //   (2) connect JuiceBox to 240V, measure the voltage on pin A1. Set the threshold to the voltage in the middle between 
  //   these two values
  // with 200k resistor from AC rectified line, we have 0.8mA peak primary current at 120VAC
  //     and 1.6mA at 240VAC
  // according to PC817X1 opto's datasheet, CTR is 80-160% at 5mA
  // typical curve suggests 80% of that at 2.5mA, 50% at 1mA
  // therefore, we have a secondary peak current of 0.3-0.6mA at 120VAC, 1-2mA at 240VAC
  // this corresponds to a secondary voltage drop: 0.3-0.6V or 1-2V per 1k of secondary resistance
  //               (actually clipped to 5V since we are using 5v supply)
  // also, need to take into account that we see the significant current only at the positive peak of AC wave
  // generally, for ~1/4 of the period for 120VAC and 1/3rd for 240VAC
  // finally, the average drop within over the drop time is ~1/2 of the peak drop
  // putting it all together, we expect average drop of 0.04-0.08V per 1k for 120VAC and 0.16-0.32V per 1k for 240VAC 
  //               (with some clipping starting at 3-5k - really becoming visible at 5-7k)  
  // Example: 4.7k secondary - 0.2-0.4V and 0.8-1.5V drops
  // Example: 10k secondary - 0.4-0.8V and 1.2-2.2V drops
  // Using 10k secondary, place mid-point at 1V drop, or 4V threshold
  // cap at 4.9V to prevent from defaulting to 120V in case when no PC817 installed at all
  if(V_Ard_pin > 3.5 && V_Ard_pin<4.9) V_AC=120;
#endif

#ifdef PCB_83
  // in 8.3 and later, the implementation changed to measurement using the GFCI current sensor
  // ~200x division factor for voltage (total gain of test loop is ~1.2e-2)
  //     (306 from RMS voltage on sensor = 680x on the opamp, 0.5x due to half-wave rectification, 0.9x for converting to average from RMS)
  //     (3.9e-5x from 0.39V/A sensor sensitivity with 390R shunt resistor, 0.0001A/V voltage-to-current conversion on a 10k resistor)
  //

  // if no GFI installed, cannot measure voltage - default to 240V 
#ifdef GFI
  V_AC=150*(V_Ard_pin-V_Ard_pin_0);
#else
  V_AC=240;
#endif

#ifdef DEBUG
  sprintf(str, "V_AC: %d", int(V_AC));
  printJBstr(0, 9, 2, 0x1f, 0, 0, str);   
#endif
  
  if(V_AC < V_AC_threshold) { // midpoint between 120 and 208V
    V_AC=120;
  } else if(V_AC < 224) { // midpoint between 208V and 240V
    V_AC=208;
  } else {
    V_AC=240; // default fall-back value
  }
  
#endif

  return V_AC; 
}
 
So im not much for code, but should I go to Microcenter and order an Ardurino usb programmer so I can reprogram it?.. starting to wander if this EVSE is over my head lol. :oops:
 
Raycreed said:
So im not much for code, but should I go to Microcenter and order an Ardurino usb programmer so I can reprogram it?.. starting to wander if this EVSE is over my head lol. :oops:

Does Microcenter carry them? If not, this is what you want. Amazon can have it to you in 2 days:
http://www.amazon.com/SparkFun-FTDI...93906232&sr=8-3&keywords=sparkfun+arduino+usb

The process of trying the code change is pretty simple.
If you can't figure it out on your own from the EMW documentation, I'll walk you through it. I may not be free for a phone call until next week, though.

Alternatively, you've probably got a friend with a teenage kid that already tinkers with these things and may be willing to fix it for you for $5. :)
Well... prices may have inflated a bit since I was a teenagers, so maybe $20.
 
http://www.microcenter.com/product/389986/OSEPP_FTDI_Breakout_Board" onclick="window.open(this.href);return false;

This is what they had at microcenter, i'm going to run out today and get it, hopefully it will work in fixing my 120/240 issue.

now looking at the code, where exactly do I put "240" so its always defaulting to 240 v? do I put it in between the Parenthesis after Read_v?

Thanks all for the help
 
Raycreed said:
http://www.microcenter.com/product/389986/OSEPP_FTDI_Breakout_Board
This is what they had at microcenter, i'm going to run out today and get it, hopefully it will work in fixing my 120/240 issue.
now looking at the code, where exactly do I put "240" so its always defaulting to 240 v? do I put it in between the Parenthesis after Read_v?
Thanks all for the help

That's the correct cable.

You can pull the source code from here: http://emotorwerks.com/JuiceBox_Public/
Then install the Arduino programming environment just as described in the juicebox manual and modify the source.

The line of code you'll be changing is this one:
Code:
inV_AC=read_V();
to be:
Code:
inV_AC=240;

Now, also important. I think you said previously that you have version 8.1 of the main board. This means that the current brand new juice box code won't just work for you right out of the box. If I'm mistaken and you actuall have a newer version of the board, then by all means ignore these comments. The version of the board is written on it in white letters, screen printed right onto the circuit board.

Near the top of the newest version of the code (EMW_EVSE_firmware_V8_7.ino, I think), you'll see a few define lines called "main switches":
Code:
//------------------------------ MAIN SWITCHES -----------------------------------
// #define DEBUG 1 // this results in many additional printouts
// the following results in much more frequent reporting of data by JuiceBox to EmotorWerks servers
// PLEASE DO NOT USE in your JuiceBox UNLESS AUTHORIZED BY EMotorWerks - this overloads our servers
// and slows down the system for everyone. JuiceBoxes that consistently report more frequently than 
// every ~1 minute will be permanently banned from our network
// #define DEBUG_WIFI 
#define AC1075
const int R_C=120; // this is the value of the shunting resistor. see datasheet for the right value. 
const int V_AC_threshold=160; // normally 164 (midpoint between 120V and 208V
// #define CT_8349-1500
// #define CT_8420-1000
// #define CT_3100
// #define JB_WiFi // is WiFi installed & we are using WiFlyHQ library?
// #define JB_WiFi_simple // is WiFi installed and we are just pushing data?
// #define LCD_SGC // old version of the u144 LCD - used in some early JuiceBoxes
//#define PCB_81 // 8.1 version of the PCB
 #define PCB_83 // 8.3+ version of the PCB, includes 8.6, 8.7 versions
 #define VerStr "V8.7.0" // detailed exact version of firmware (thanks Gregg!)
 #define GFI // need to be uncommented for GFI functionality
 #define trim120current
// #define BuzzerIndication // indicate charging states via buzzer - only on V8.7 and higher
//------------------------------- END MAIN SWITCHES ------------------------------

You need to change a few lines in the middle:
Code:
#define PCB_81 // 8.1 version of the PCB
//#define PCB_83 // 8.3+ version of the PCB, includes 8.6, 8.7 versions
//#define GFI // need to be uncommented for GFI functionality
#define trim120current // This one is optional, it will guarantee that your adjustment pot still works even if 120 is detected.

Of course these depend on what you actually have. If you have GFI, I'm guessing no. And if you actually have PCB 8.1
Let me know if this all makes sense. Good luck.
 
My Juicebox is marked as version 8.3. I have the programmer, and from what you said it sounds pretty simple. hopefully this works
 
Raycreed said:
My Juicebox is marked as version 8.3. I have the programmer, and from what you said it sounds pretty simple. hopefully this works

Cool. If you've got an 8.3, then don't touch the defines.
First I'd try the new 8.7 version of the code as is. If that works, GREAT.
If not, next I'd try setting V_AC = 240;
If that still doesn't work, next I try setting the duty cycle manually.

Override this chunk of code, by adding the line in at the end that overrides the duty cycle to 50% (30 amps).
Feel free to replace with your own duty cycle.

Code:
  // per J1772 standard:
  // 1% duty = 0.6A until 85% duty cycle
  // after that, 1% = 2.5A up to 96%
  if(outC<51) {
    duty=PWM_res*outC/60.;
  } else {
    duty=PWM_res*(0.64+outC/250.);
  }

  duty = 500; // <-- add this line, overrides calculation above. 500 = 50% = 30 amps.

Good luck.
 
I would love to make changes and upload to the Arduino, but every time I try to upload, it says "expected constructor, Destructor or type conversion before "*" token, as well as a few more errors.. this is unedited firmware that I downloaded from emw, and its not letting me load it to the EVSE because of these errors...

I'm trying to do this while the unit is unplugged.. do I need to program it while its plugged in? :?

Serial monitor is showing a repeating display showing Volts, amps, duty, etc.
 
Raycreed said:
I would love to make changes and upload to the Arduino, but every time I try to upload, it says "expected constructor, Destructor or type conversion before "*" token, as well as a few more errors.. this is unedited firmware that I downloaded from emw, and its not letting me load it to the EVSE because of these errors...

I'm trying to do this while the unit is unplugged.. do I need to program it while its plugged in? :?

Serial monitor is showing a repeating display showing Volts, amps, duty, etc.

I will try this when I get home after work (probably not before 9 or 10 pacific time). And make detailed steps of what I did.
You should be able to compile without plugging into your juicebox. It should just fail the upload step.
 
Nevermind, I found out why it wouldn't compile. I didn't have the Library files in my c\arduino\libraries folder. Will try to edit it now and see if I can get it to work right. I've successfully compiled it so I just need to load it.. hopefully this works and makes my evse work at 6.6kw now.
 
Raycreed said:
Did you need to make any changes to the code?

Yea, just the read_V, my juicebox is 240v hookup only, but thats ok, I'll just use the nissan evse for L1 charging.

Interesting. If you've got an email thread going with EMW, let Valery know that you needed to hack this. I'm sure he'll be interested in root-causing this bug to fix in a future rev.
 
I'm wandering, just in case, could all my problems had happened because my voltage was over 240? its usually 244volts without load, then it goes to 242v when I start charging. maybe the programming wasn't set for over 240 volts? thats the only reason I could think as to why it wouldn't work right when I got my juicebox. Valery said that they were working on a hardware fix in an e-mail, but I let them know that I have it working now with the change of programming.
 
Firmware V8.7.2 posted on JuiceBox site at http://emotorwerks.com/JuiceBox_Public/8.7/50%20-%20Firmware/8.7.2/" onclick="window.open(this.href);return false;.

New features:
* Proper interface for a settings menu using the LCD and wireless remote
* Menu option 1: Current limit change at any time via a wireless remote - both for 120V and 240V operation
* Menu option 2: JuiceBox ID printout for WiFi data reporting
* Menu option 3: Clock setup at any time via a remote
* Various refactorings and minor bug fixes

This version matches kits / units V8.7.2 shipping now.

Val
 
Nearly a month later, it's happening again. 2 days in a row again. I guess it's reboot time.
Valery, is this one of the "minor" bugfixes that you are reporting fixed below? I'll flash the firmware to be the newest, also so it gets power cycled.
But since it takes a month to reproduce the error, I won't know if it's fixed for a month when I go to use my car and realize it isn't charged.

Valery, let me know if you are already aware of this and/or what debugging steps you recommend.
I haven't rebooted it yet, so if there's a way to hook up debug output without resetting it, I can still do that.


Levi8than said:
It's been raining the last couple of days, and I expect it to continue. This is pretty much the first heavy rain since I installed my Juicebox. The juicebox is indoors, with the cable run out through a little door and the end being stored on a printed PLA hanger:

I'm not sure if sharing images this way works. Let's try it:
20140118_174317.jpg


It's been working flawlessly since early January when I got it working. And now for the second day in a row, my car is reporting an EV system panic and not charging completely. The car is set to charge to 80%. Today I only got 75%, yesterday I only got 72%.
Do you think the rain is to blame? It's the only thing I know that has changed. And do I contact Nissan because there's an issue on their end, or look at the plug coming from my juicebox? Any thoughts? Everything I've looked at suggests that charging in the rain should be fine, and that the access door is properly drained.

20140227_085430.jpg
 
Back
Top