Skip to main content

Messages

This section allows you to view all Messages made by this member. Note that you can only see Messages made in areas you currently have access to.

Messages - jlvern

1
Bus Pirate Development / Re: Horrible "float"
Oups ! Mistake !
#define ADC_MAX 1023UL
// for correct rounded mV value :
#define ADC_VOLTS(x)   ((((unsigned long)(x)*V_REF)+ADC_MAX/2)/ADC_MAX)
2
Bus Pirate Development / Re: 400mV p-p ripple (6.667kHz) on my BusPirate v3b 3.3V lin
Thanks... No... The problem is not the joints.
I try with another output capacitor (X7R 10uF), and now the oscillation is 3.4kHz. I try to put an input capacitor (10uF X7R) directly on the regulators pins : no effect...

Well, no problem, I remove the  Grrr/!ยง% Torex regulator and I put a good TPS79933 TI regulator (same pinout)
and now, all is OK with this good (fast and low noise) regulator !
4
Bus Pirate Development / Horrible "float"
Hello,
I just discovered "Bus Pirate" and I think it's a good project.
But ... reading the code I discover horrible "float" in two functions: void bpPWM (void) void bpWvolts (unsigned int a).
The utisation to "float" is contrary to my religion (unless I have a gun to his head), so I can provide you with a few lines of code using integers to replace those horrible ineffective  "float"...

Best regards,
Jean-Louis Vern

1) In bpPWM
#define FCY   16000000UL
   unsigned int PWM_pd;
   unsigned long PWM_freq_Hz;
...
   // no prescaler
   T2CONbits.TCKPS0=0;
   T2CONbits.TCKPS1=0;
   // PWM freq in Hz
   PWM_freq_Hz  = __builtin_muluu( PWM_freq, 1000 );
   // PWM period in cycles (rounded)
   PWM_period    = (FCY + (PWM_freq_Hz/2)) / PWM_freq_Hz;
   // rounded duty cycle
   PWM_dutycycle = __builtin_divud( __builtin_muluu( PWM_period, PWM_pd)+50, 100);

   //assign pin with PPS
   AUXPIN_RPOUT = OC5_IO;

   OC5R = PWM_dutycycle;
   OC5RS = PWM_dutycycle;
   OC5CON = 0x6;         
   PR2   = PWM_period - 1;   
...

2) In bpWvolts()

#define   R_LOW      10UL
#define   R_HIGH      10UL
#define V_REF      3300UL
#define ADC_MAX      1024UL

#define R_DIV(x)   ((((x)*(R_LOW+R_HIGH))+(R_LOW/2))/R_LOW)
#define ADC_VOLTS(x)   (((unsigned long)(x)*V_REF)/ADC_MAX)

#include <stdlib.h> /* for div, div_t */
void bpWvolts(unsigned int a)
{
   unsigned int v;
   div_t div_res;
   // value with V_REF resolution (1mV)
   v = (unsigned int)ADC_VOLTS( R_DIV(a) );
   // rounding to 10mV
   v = (v+5)/10;
   // integer part (V) in div_res.quot, fract (1/100V) in div_res.rem
   div_res = div( v, 100 );
   bpWdec( div_res.quot );
   UART1TX('.');
   // remainder (1/100V, 00..99)
   div_res = div( div_res.rem, 10 );
   UART1TX( div_res.quot + '0' );
   UART1TX( div_res.rem  + '0' );
}

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01332302576session_write_close ( )...(null):0
20.01362434176ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01362434952Database_MySQL->query( ).../DatabaseHandler.php:119
40.05782573696Database_MySQL->error( ).../Db-mysql.class.php:273